Re: ON_UPDATE_COMMAND_UI handler does not get called
Joseph M. Newcomer <newcomer@flounder.com> wrote in
news:jp2fj3htvoqhc0oqdb8l6kbr1nm9psug2i@4ax.com:
I've not seen failures like this. I think this is going to take some
investigation. I'd probably end up putting a conditional breakpoint
in the MFC dispatcher looking for commands with ID_EDIT_CLEAR in them.
joe
I have. I've never really been able to figure out why, but sometimes
depending on the window you are in, and the menu (context, app, etc) you
use, the cmdui stuff just doesn't kick in. I've added the following code
more often than I care to... (using some vc8 tricks, and lazy typing):
void yourClassThatHandlesTheMenu::OnInitMenuPopup(CMenu* pPopupMenu, UINT
nIndex, BOOL bSysMenu)
{
__super::OnInitMenuPopup(...)
CCmdUI cmdUI;
cmdUI.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (UINT n = 0; n < cmdUI.m_nIndexMax; ++n)
{
cmdUI.m_nIndex = n;
cmdUI.m_nID = pPopupMenu->GetMenuItemID(cmdUI.m_nIndex);
cmdUI.m_pMenu = pPopupMenu;
cmdUI.DoUpdate(pTarget, FALSE);
}
}
That always seems to do the trick... (Oh, and make sure you have
ON_WM_INITMENUPOPUP in your message map). I came across that once a
number of years ago...
Dave Connet