Problem disabling submenu item (Repost for Co-worker )
-
I am unable to disable a second level menu item. I have a Tools popup menu on my menubar that contains two items and a popup item that also contains two menu items. It looks like this:
Tools
|--- Item1
|--- Item2
|---- SubItem1
|---- SubItem2I used ClassWizard to add the usual ON_UPDATE_COMMAND_UI functions. In the appropriate function, I can use "pCmdUI->Enable(FALSE)" to disable "Item", but I can't disable "SubItem1" and "SubItem2". Matter of fact, the functions that ClassWizard generated for my two sub menu items are never even called. I have breakpoints on both these function and they are never even hit. This bug occurs on both my emulator and on my Compaq iPaq (arm processor). I created the project with AppWizard and am using a "Basic MenuBar". Any ideas? Can anyone else disable a submenu item? [edit] Forgot to mention that this is for PocketPC 2002. [/edit] ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
I am unable to disable a second level menu item. I have a Tools popup menu on my menubar that contains two items and a popup item that also contains two menu items. It looks like this:
Tools
|--- Item1
|--- Item2
|---- SubItem1
|---- SubItem2I used ClassWizard to add the usual ON_UPDATE_COMMAND_UI functions. In the appropriate function, I can use "pCmdUI->Enable(FALSE)" to disable "Item", but I can't disable "SubItem1" and "SubItem2". Matter of fact, the functions that ClassWizard generated for my two sub menu items are never even called. I have breakpoints on both these function and they are never even hit. This bug occurs on both my emulator and on my Compaq iPaq (arm processor). I created the project with AppWizard and am using a "Basic MenuBar". Any ideas? Can anyone else disable a submenu item? [edit] Forgot to mention that this is for PocketPC 2002. [/edit] ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
I did some research on this and found the following (file winfrm.cpp, line 1607 of the MFC sources):
if (state.m_nID == (UINT)-1)
{
// possibly a popup menu, route to first item of that popup
state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // first item of popup can't be routed to
}
state.DoUpdate(this, FALSE); // popups are never auto disabled
}
else
{
// normal menu item
// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, m_bAutoMenuEnable && state.m_nID < 0xF000);
}This seems to imply that MFC does not allow that.
-
I did some research on this and found the following (file winfrm.cpp, line 1607 of the MFC sources):
if (state.m_nID == (UINT)-1)
{
// possibly a popup menu, route to first item of that popup
state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // first item of popup can't be routed to
}
state.DoUpdate(this, FALSE); // popups are never auto disabled
}
else
{
// normal menu item
// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, m_bAutoMenuEnable && state.m_nID < 0xF000);
}This seems to imply that MFC does not allow that.
He doesn't want to disable a popup menu, he want's disable one of the items in it. ClassWizard allowed him to create OnUpdate handlers for the subitems, but that code isn't being called at all. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
He doesn't want to disable a popup menu, he want's disable one of the items in it. ClassWizard allowed him to create OnUpdate handlers for the subitems, but that code isn't being called at all. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends