Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Flickering 1) title bar, 2) controls Collapse All
Subject Author Date
Dylan da Silva Apr 21, 2010 - 2:36 PM

The first issue is that the title bar flickers between Prof-UIS and old school classic windows when ever you drag the window around or resize it.  And if you change the text in the title bar at regular intervals it will sometimes appear (drawn) like classic windows until I interact with the menu or toolbar.


The second issue is that I have a dialog derived from CExtResizableDialog and I have several controls like a slider, etc. all of which are surrounded by a Group Box.  When the slider is moved the Group Box (which has a control attached because i change the text periodically while using the dialog) flickers.  it’s not just once in a blue moon it’s the entire time I’m dragging any of the 5 sliders in the dialog around.  Inside and outside the boundary of the group box.


These seem related somehow.  Like Windows is still rendering the window whatever way it used, but then Prof-UIS jumps in and paints over that.


Regardless, how can i make the flickering stop?

Dylan da Silva Apr 27, 2010 - 10:56 AM



1) Your dialog template resource has both WS_CLIPCHILDREN|WS_CLIPSIBLINGS styles.


Yes.



2) The Z-order of all the group boxes should be larger than the Z-orders of all the controls "inside" groupboxes.


Yes.

Technical Support Apr 28, 2010 - 10:15 AM

The dialog controls should also have the WS_CLIPCHILDREN|WS_CLIPSIBLINGS styles set on, including group boxes.
Do you have any DirectX/OpenGL/Video output in your dialog? If yes, then the hardware accelerated output should be performed in a standalone window create as a child of your dialog.

Dylan da Silva Apr 28, 2010 - 11:32 AM

It did not fix the issue.  I strongly believe this issue is related to the title bar issue.  I have managed to alleviate the flickering int he dialog by only calling SetWindowText() on SB_ENDSCROLL.  But the title bar could changed as often as once a second.

Technical Support Apr 28, 2010 - 12:43 PM

Then we need your help in reproducing this flickering issue with any of our sample applications or with some simple test project.

Dylan da Silva Apr 29, 2010 - 8:27 AM

How should I go about getting the binary to you?  Email?

Technical Support May 3, 2010 - 8:22 AM

You can contact us by email at support@prof-uis.com.

Dylan da Silva May 11, 2010 - 7:20 AM

Okay, I’m sorry it took so long.  I found an application that could be modified easily enough.  In Prof-UIS sample FunnyBars, add the following code to the end of the _UpdateHotBar function:



CString str;
    srand((unsigned int)time(NULL) ˆ clock());
    str.Format("This is a random number: %d",rand());
    this->m_wndBoxBrightness.SetWindowText(str);
    str.Format("Another random number: %d",rand());
    this->m_wndBoxFont.SetWindowText(str);

You’ll see that as you drag the brightness slider around the group boxes for Brightness and Font flicker.  The flickering is noticeable when using any theme but is most noticeable when using the Office 2007 Obsidian and Office 2010 Black.

Technical Support May 11, 2010 - 12:55 PM

Thank you for reporting this issue. To fix it, please update the source code for the following method:

LRESULT CExtGroupBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
#if (defined WM_UPDATEUISTATE)       
            ASSERT( WM_UPDATEUISTATE == 0x0128 );
#endif
            // WM_UPDATEUISTATE causes repaint without WM_PAINT, so we eat it
            if( message == 0x0128 )
                        return 0;
            if(                     message == WM_SETTEXT 
                        ||           message == WM_ENABLE
                        
                        )
            {
                        SetRedraw( FALSE );
                        LRESULT lResult = CButton::WindowProc(message, wParam, lParam);
                        SetRedraw( TRUE );
                        Invalidate();
                        UpdateWindow();
                        return lResult;
            }
            if( message == WM_PRINT || message == WM_PRINTCLIENT )
            {
                        CDC * pDC = CDC::FromHandle( (HDC)wParam );
                        CRect rcClient;
                        GetClientRect( &rcClient );
                        DoPaint( pDC, rcClient );
                        return (!0);
            }           
            return CButton::WindowProc(message, wParam, lParam);
}

Dylan da Silva May 12, 2010 - 6:34 AM

This fix worked.  Thank you.


Any movement on the non-client window title bar redraw issue?

Technical Support May 12, 2010 - 9:56 AM

Still didn’t reproduce the window caption flicker. We used the modified version of the PageContainer sample application where we added the following code into the beginning of the CMainFrame::PreTranslateMessage() message:

   if( pMsg->message == WM_TIMER && pMsg->hwnd == m_hWnd && pMsg->wParam == 111 )
            {
                        static unsigned long garbage = 0;
                        CString str;
                        str.Format("This text has been set %d times...",garbage++);
                        SetWindowText(str);
                        return TRUE;
            }

We started the timer in the following method:
void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
            pOldWnd;
            // forward focus to the view window
CView * pView = GetActiveView();
            if( pView != NULL )
                        pView->SetFocus();

            SetTimer( 111, 200, NULL );
}

Dylan da Silva May 12, 2010 - 12:27 PM

I never tried it with PageContainer because it doesn’t accurately represent our application which is an MDI application with one or more threads that that signal a window title change.  The header and source file I posted previously is almost exactly what we’re doing.  That has to work.


In the MDI application, we instantiate the App then create a child window that we maximize immediately.  So all the user sees a single window filling their entire screen.  Now at any instant we could change the window text.  For the sample I posted earlier, I chose 1 second interval to demonstrate the issue in an efficient manner.  What you should see if you double click the title bar is the window shrink slightly, then when you click maximize the window fills the screen again and the titlebar will be redrawn like old school windows.  If you cannot reproduce the bug then I’ll go so far as to screen grab or FRAPS the event and send it to you.


Keep in mind that this isn’t a consistent event, but it happens frequently enough that it’s very, very noticeable.

Technical Support May 13, 2010 - 12:52 PM

It would be very helpful if you show us how to reproduce this issue using any of our sample apps.

Dylan da Silva May 13, 2010 - 5:10 PM

From May 12th, 2010:


"I never tried it with PageContainer because it doesn’t accurately represent our application which is an MDI application with one or more threads that that signal a window title change.  The header and source file I posted previously is almost exactly what we’re doing.  That has to work."


From April 23rd, 2010:


I had some spare time while I was waiting for an answer so I fooled around with the "MDI" sample project.  Copy the following code into the project, file->new, maximize the child window, maximize the main window.  What you should see is the title bar turning into classic windows (or whatever theme you have on your PC) and staying that way.


// ChildFrm.h : interface of the CChildFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_)
#define AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ChildView.h"

// my stuff ///// begin
class CMyThread : public CWinThread
{
public:
    CMyThread(CFrameWnd* wnd) : m_wnd(wnd), m_working(TRUE) {}
    ~CMyThread(void) {}

    CFrameWnd* GetWnd(void) { return m_wnd; }
    BOOL IsNotDone(void) { return m_working; }
    void StopThread(void) { m_working = FALSE; }
private:
    CFrameWnd* m_wnd;
    BOOL m_working;
};
// my stuff ///// end

class CChildFrame : public CExtNCW < CMDIChildWnd >
{
    DECLARE_DYNCREATE(CChildFrame)
public:
    CChildFrame();

// Attributes
public:

private:
    HICON m_hChildFrameIcon;

// Operations
public:

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CChildFrame)
    public:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    //}}AFX_VIRTUAL

// Implementation
public:
    // view for the client area of the frame.
    CChildView m_wndView;
    virtual ~CChildFrame();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
    //{{AFX_MSG(CChildFrame)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    afx_msg void OnFileClose();
    afx_msg void OnSetFocus(CWnd* pOldWnd);
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnDestroy(void);
    // my stuff ///// begin
    afx_msg LRESULT OnChangeTitleMessage(WPARAM wparam, LPARAM lparam);
    // my stuff ///// end
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    // my stuff ///// begin
private:
    CMyThread* m_thread;
    // my stuff ///// end
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_)

 


// ChildFrm.cpp : implementation of the CChildFrame class
//

#include "stdafx.h"
#include "MDI.h"

#include "ChildFrm.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// my stuff ///// begin
UINT MyThreadProc( LPVOID pParam );
// my stuff ///// end

static int count = 0;
static const UINT MPM_CHANGE_TITLE_MESSAGE = ::RegisterWindowMessage("MPM_CHANGE_TITLE_MESSAGE");

/////////////////////////////////////////////////////////////////////////////
// CChildFrame

IMPLEMENT_DYNCREATE( CChildFrame, CMDIChildWnd )

BEGIN_MESSAGE_MAP( CChildFrame, CMDIChildWnd )
    //{{AFX_MSG_MAP(CChildFrame)
    ON_REGISTERED_MESSAGE(MPM_CHANGE_TITLE_MESSAGE,OnChangeTitleMessage)
    ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
    ON_WM_SETFOCUS()
    ON_WM_CREATE()
    ON_WM_DESTROY()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

// my stuff ///// begin
LRESULT CChildFrame::OnChangeTitleMessage(WPARAM, LPARAM)
{
    // do Fibanacci
    unsigned long long garbage = 24;
    for(int i=0;i<1000;++i)
        garbage *= (unsigned long long)i;
    // then set window text
    CString str;
    str.Format("This text has been set %d times...",count++);
    SetWindowText(str);
    return 0;
}
// my stuff ///// end

/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction

CChildFrame::CChildFrame()
{
    // TODO: add member initialization code here
    
    m_hChildFrameIcon = NULL;
HINSTANCE hInstResource =
        AfxFindResourceHandle(
            MAKEINTRESOURCE(IDR_MDITYPE),
            RT_GROUP_ICON
            );
    ASSERT( hInstResource != NULL );
    if( hInstResource != NULL )
    {
        m_hChildFrameIcon =
            (HICON)::LoadImage(
                hInstResource,
                MAKEINTRESOURCE(IDR_MDITYPE),
                IMAGE_ICON,
                16,
                16,
                0
                );
        ASSERT( m_hChildFrameIcon != NULL );
    }
}

CChildFrame::~CChildFrame()
{
    if( m_hChildFrameIcon != NULL )
    {
        ::DestroyIcon( m_hChildFrameIcon );
    }

}

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( ! CExtNCW < CMDIChildWnd > :: PreCreateWindow( cs ) )
        return FALSE;
    cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
    cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
    cs.lpszClass = AfxRegisterWndClass( 0 );
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics

#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
    CExtNCW < CMDIChildWnd > :: AssertValid();
}

void CChildFrame::Dump(CDumpContext& dc) const
{
    CExtNCW < CMDIChildWnd > :: Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
void CChildFrame::OnFileClose() 
{
    // To close the frame, just send a WM_CLOSE, which is the equivalent
    // choosing close from the system menu.

    SendMessage(WM_CLOSE);
}

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if( CExtNCW < CMDIChildWnd > :: OnCreate( lpCreateStruct ) == -1 )
        return -1;

    ASSERT( m_hChildFrameIcon != NULL );
    SetIcon( m_hChildFrameIcon, FALSE );
    SetIcon( m_hChildFrameIcon, TRUE );

    // create a view to occupy the client area of the frame
    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, 
        CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }

    // my stuff ///// begin
    m_thread = new CMyThread((CFrameWnd*)this);
    AfxBeginThread(MyThreadProc, m_thread);
    // my stuff ///// end

    return 0;
}

void CChildFrame::OnDestroy()
{
    // my stuff ///// begin
    m_thread->StopThread();
    m_thread->Delete();
    // my stuff ///// end
    CExtNCW < CMDIChildWnd > :: OnDestroy();
}

void CChildFrame::OnSetFocus(CWnd* pOldWnd) 
{
    CExtNCW < CMDIChildWnd > :: OnSetFocus(pOldWnd);
    if( m_wndView.GetSafeHwnd() != NULL )
        m_wndView.SetFocus();
}

BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
    // let the view have first crack at the command
    if(        m_wndView.GetSafeHwnd() != NULL
        &&    m_wndView.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo )
        )
        return TRUE;
    // otherwise, do default handling
    return CExtNCW < CMDIChildWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}


BOOL CChildFrame::PreTranslateMessage(MSG* pMsg) 
{
CMainFrame * pMainFrame =
        DYNAMIC_DOWNCAST(
            CMainFrame,
            ::AfxGetMainWnd()
            );
    ASSERT_VALID( pMainFrame );
    if( pMainFrame->m_wndMenuBar.TranslateMainFrameMessage(pMsg) )
        return TRUE;
    return CExtNCW < CMDIChildWnd > :: PreTranslateMessage(pMsg);
}

// my stuff ///// begin
UINT MyThreadProc( LPVOID pParam )
{
    CMyThread* pThread = (CMyThread*)pParam;

    if (pThread == NULL)
        return 1;

    while (pThread->IsNotDone())
    {
        pThread->GetWnd()->PostMessage(MPM_CHANGE_TITLE_MESSAGE);
        Sleep(1000);
    }

    return 0;   // thread completed successfully
}
// my stuff ///// end

Dylan da Silva May 11, 2010 - 1:21 PM

Any idea if something similar will fix the title bar repainting issue?  Can I find a spot to make the same mod to ensure the Title bar is redrawn properly when we use mainFrame->SetWindowText()?

Technical Support May 12, 2010 - 9:58 AM

We checked the title bar text changing in Prof-UIS 2.89 and it’s OK. The older Prof-UIS versions may require sending the WM_NCPAINT message after changing window text.

Dylan da Silva May 12, 2010 - 12:20 PM

Should i just SendMessage(WM_NCPAINT) after I change the title text?  Or is their a tighter way to make sure this bug is fixed?

Technical Support May 13, 2010 - 12:51 PM

To sending a WM_NCPAINT message is enough. Please note, this issue with window text changing is gone in the latest Prof-UIS version.

Technical Support Apr 27, 2010 - 10:28 AM

Please check the following:

1) Your dialog template resource has both WS_CLIPCHILDREN|WS_CLIPSIBLINGS styles.

2) The Z-order of all the group boxes should be larger than the Z-orders of all the controls "inside" groupboxes.

Dylan da Silva Apr 23, 2010 - 1:52 PM

I had some spare time while I was waiting for an answer so I fooled around with the "MDI" sample project.  Copy the following code into the project, file->new, maximize the child window, maximize the main window.  What you should see is the title bar turning into classic windows (or whatever theme you have on your PC) and staying that way.



// ChildFrm.h : interface of the CChildFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_)
#define AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ChildView.h"

// my stuff ///// begin
class CMyThread : public CWinThread
{
public:
    CMyThread(CFrameWnd* wnd) : m_wnd(wnd), m_working(TRUE) {}
    ~CMyThread(void) {}

    CFrameWnd* GetWnd(void) { return m_wnd; }
    BOOL IsNotDone(void) { return m_working; }
    void StopThread(void) { m_working = FALSE; }
private:
    CFrameWnd* m_wnd;
    BOOL m_working;
};
// my stuff ///// end

class CChildFrame : public CExtNCW < CMDIChildWnd >
{
    DECLARE_DYNCREATE(CChildFrame)
public:
    CChildFrame();

// Attributes
public:

private:
    HICON m_hChildFrameIcon;

// Operations
public:

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CChildFrame)
    public:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    //}}AFX_VIRTUAL

// Implementation
public:
    // view for the client area of the frame.
    CChildView m_wndView;
    virtual ~CChildFrame();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
    //{{AFX_MSG(CChildFrame)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    afx_msg void OnFileClose();
    afx_msg void OnSetFocus(CWnd* pOldWnd);
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnDestroy(void);
    // my stuff ///// begin
    afx_msg LRESULT OnChangeTitleMessage(WPARAM wparam, LPARAM lparam);
    // my stuff ///// end
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    // my stuff ///// begin
private:
    CMyThread* m_thread;
    // my stuff ///// end
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CHILDFRM_H__24FC4FC8_9EB2_47D0_8A72_FBE881021D1D__INCLUDED_)

// ChildFrm.cpp : implementation of the CChildFrame class
//

#include "stdafx.h"
#include "MDI.h"

#include "ChildFrm.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// my stuff ///// begin
UINT MyThreadProc( LPVOID pParam );
// my stuff ///// end

static int count = 0;
static const UINT MPM_CHANGE_TITLE_MESSAGE = ::RegisterWindowMessage("MPM_CHANGE_TITLE_MESSAGE");

/////////////////////////////////////////////////////////////////////////////
// CChildFrame

IMPLEMENT_DYNCREATE( CChildFrame, CMDIChildWnd )

BEGIN_MESSAGE_MAP( CChildFrame, CMDIChildWnd )
    //{{AFX_MSG_MAP(CChildFrame)
    ON_REGISTERED_MESSAGE(MPM_CHANGE_TITLE_MESSAGE,OnChangeTitleMessage)
    ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
    ON_WM_SETFOCUS()
    ON_WM_CREATE()
    ON_WM_DESTROY()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

// my stuff ///// begin
LRESULT CChildFrame::OnChangeTitleMessage(WPARAM, LPARAM)
{
    // do Fibanacci
    unsigned long long garbage = 24;
    for(int i=0;i<1000;++i)
        garbage *= (unsigned long long)i;
    // then set window text
    CString str;
    str.Format("This text has been set %d times...",count++);
    SetWindowText(str);
    return 0;
}
// my stuff ///// end

/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction

CChildFrame::CChildFrame()
{
    // TODO: add member initialization code here
    
    m_hChildFrameIcon = NULL;
HINSTANCE hInstResource =
        AfxFindResourceHandle(
            MAKEINTRESOURCE(IDR_MDITYPE),
            RT_GROUP_ICON
            );
    ASSERT( hInstResource != NULL );
    if( hInstResource != NULL )
    {
        m_hChildFrameIcon =
            (HICON)::LoadImage(
                hInstResource,
                MAKEINTRESOURCE(IDR_MDITYPE),
                IMAGE_ICON,
                16,
                16,
                0
                );
        ASSERT( m_hChildFrameIcon != NULL );
    }
}

CChildFrame::~CChildFrame()
{
    if( m_hChildFrameIcon != NULL )
    {
        ::DestroyIcon( m_hChildFrameIcon );
    }

}

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( ! CExtNCW < CMDIChildWnd > :: PreCreateWindow( cs ) )
        return FALSE;
    cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
    cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
    cs.lpszClass = AfxRegisterWndClass( 0 );
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics

#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
    CExtNCW < CMDIChildWnd > :: AssertValid();
}

void CChildFrame::Dump(CDumpContext& dc) const
{
    CExtNCW < CMDIChildWnd > :: Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
void CChildFrame::OnFileClose() 
{
    // To close the frame, just send a WM_CLOSE, which is the equivalent
    // choosing close from the system menu.

    SendMessage(WM_CLOSE);
}

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if( CExtNCW < CMDIChildWnd > :: OnCreate( lpCreateStruct ) == -1 )
        return -1;

    ASSERT( m_hChildFrameIcon != NULL );
    SetIcon( m_hChildFrameIcon, FALSE );
    SetIcon( m_hChildFrameIcon, TRUE );

    // create a view to occupy the client area of the frame
    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, 
        CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }

    // my stuff ///// begin
    m_thread = new CMyThread((CFrameWnd*)this);
    AfxBeginThread(MyThreadProc, m_thread);
    // my stuff ///// end

    return 0;
}

void CChildFrame::OnDestroy()
{
    // my stuff ///// begin
    m_thread->StopThread();
    m_thread->Delete();
    // my stuff ///// end
    CExtNCW < CMDIChildWnd > :: OnDestroy();
}

void CChildFrame::OnSetFocus(CWnd* pOldWnd) 
{
    CExtNCW < CMDIChildWnd > :: OnSetFocus(pOldWnd);
    if( m_wndView.GetSafeHwnd() != NULL )
        m_wndView.SetFocus();
}

BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
    // let the view have first crack at the command
    if(        m_wndView.GetSafeHwnd() != NULL
        &&    m_wndView.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo )
        )
        return TRUE;
    // otherwise, do default handling
    return CExtNCW < CMDIChildWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}


BOOL CChildFrame::PreTranslateMessage(MSG* pMsg) 
{
CMainFrame * pMainFrame =
        DYNAMIC_DOWNCAST(
            CMainFrame,
            ::AfxGetMainWnd()
            );
    ASSERT_VALID( pMainFrame );
    if( pMainFrame->m_wndMenuBar.TranslateMainFrameMessage(pMsg) )
        return TRUE;
    return CExtNCW < CMDIChildWnd > :: PreTranslateMessage(pMsg);
}

// my stuff ///// begin
UINT MyThreadProc( LPVOID pParam )
{
    CMyThread* pThread = (CMyThread*)pParam;

    if (pThread == NULL)
        return 1;

    while (pThread->IsNotDone())
    {
        pThread->GetWnd()->PostMessage(MPM_CHANGE_TITLE_MESSAGE);
        Sleep(1000);
    }

    return 0;   // thread completed successfully
}
// my stuff ///// end

Dylan da Silva Apr 22, 2010 - 4:06 PM

Some additional information: It’s an MDI application but only running one child window (document), when the entire window (mainframe) is smaller than the screen (not maximized) the title bar is fine (almost always, 99.9%)  When the window is maximized it’s constantly painting the title bar wrong.  When the mainframe is maximized but the document (child window) is not maximized the title bar is fine even when the window text is changed.  It only seems to be an issue when both the main window is maximized and the child window within it is maximized.  This also happens to be the normal state of the application while it’s being used.