tags:

views:

20

answers:

0

My job requires me to maintain some old MFC programs, and I've been asked to add a CButton to an existing dialog. Even though my code calls CWnd::EnableWindow to enable the button, CCmdUI::Enable disables it.

Here is part of the stack trace at the moment CWnd::Enable disables the button.

mfc90d.dll!CWnd::EnableWindow()
mfc90d.dll!CCmdUI::Enable()
mfc90d.dll!CCmdUI::DoUpdate()
mfc90d.dll!CWnd::UpdateDialogControls()
mfc90d.dll!CMFCReBar::OnUpdateCmdUI()
mfc90d.dll!CControlBar::OnIdleUpdateCmdUI()
mfc90d.dll!CWnd::OnWndMsg()
mfc90d.dll!CWnd::WindowProc()
mfc90d.dll!CControlBar::WindowProc()
mfc90d.dll!AfxCallWndProc()
mfc90d.dll!CWnd::SendMessageToDescendants()
mfc90d.dll!CWnd::SendMessageToDescendants()
mfc90d.dll!CWinThread::OnIdle()
mfc90d.dll!CWinApp::OnIdle()

This does not happen to other buttons on the same dialog, so I am perplexed why MFC should single out this button for disabling.

Any help on how to prevent CCmdUI from disabling the button is appreciated.