Please add the following properties into your CWnd
-derived class:
protected:
bool m_bEnabledControlBarUpdate:1, m_bInConrolBarUpdate:1;
And initialize them in constructor(s):
: m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
The
m_bEnabledControlBarUpdate
property should be set to
true
in the
PreSubclassWindow()
virtual method:
void CExtResizableDialog::PreSubclassWindow()
{
CWnd::PreSubclassWindow();
m_bEnabledControlBarUpdate = true;
}
It should be set to
false
in the
PreSubclassWindow()
virtual method:
void CExtResizableDialog::PostNcDestroy()
{
m_bEnabledControlBarUpdate = false;
CWnd::PostNcDestroy();
}
The
WindowProc()
virtual method should invoke the
CExtControlBar::DoCustomModeUpdateControlBars()
static method which does command updating invocations:
LRESULT CExtResizableDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
bool bUpdateBarsOnThisMsg = false;
if( m_bEnabledControlBarUpdate )
{
CWinApp * pApp = AfxGetApp();
ASSERT( pApp != NULL );
BOOL bIdleMsg = pApp->IsIdleMessage(
#if _MFC_VER < 0x700
&pApp->m_msgCur
#else
&(::AfxGetThreadState()->m_msgCur)
#endif
);
if( bIdleMsg )
bUpdateBarsOnThisMsg = true;
}
HWND hWndThis = m_hWnd;
LRESULT lResult = CWnd::WindowProc(message, wParam, lParam);
if( hWndThis == NULL
|| ( ! ::IsWindow(hWndThis) )
)
bUpdateBarsOnThisMsg = false;
if( bUpdateBarsOnThisMsg
&& ( ! m_bInConrolBarUpdate )
)
{
m_bInConrolBarUpdate = true;
CExtControlBar::DoCustomModeUpdateControlBars( this );
m_bInConrolBarUpdate = false;
}
return lResult;
}