PRB: Accelerator Key Not Disabled with ON_UPDATE_COMMAND_UILast reviewed: July 22, 1997Article ID: Q120598 |
1.50 1.51 1.52
WINDOWS
kbprg kbprb
The information in this article applies to:
SYMPTOMSIf a popup menu contains a submenu and a menu item on that submenu uses an accelerator key, you can't enable or disable the accelerator key by calling CCmdUI::Enable() in the ON_UPDATE_COMMAND_UI for that menu item.
ExampleFor example, if an application has the following menu structure for the main application window, pressing CTRL+M sends the command for MenuItem.
File Other Popup MenuItem Ctrl+M Item Ctrl+TThe MenuItem command can be disabled and enabled by using an ON_UPDATE_COMMAND_UI() handler such as this:
void CMyView::OnUpdateMenuItem(CCmdUI* pCmdUI) { pCmdUI->Enable(m_bEnabled); }However, this doesn't enable or disable the accelerator key (CTRL+M). To see whether the accelerator was disabled or enabled correctly, select the MenuItem menu item manually by choosing "Other," then "Popup," and then "MenuItem." This calls the ON_UPDATE_COMMAND_UI() function to disable (grey out) the MenuItem command.
CAUSEThe ON_UPDATE_COMMAND_UI() handler is called for menu items from the OnInitMenuPopup() handler of the menu's frame window. Windows only sends the WM_INITMENUPOPUP message to top-level popups, not submenus, when an accelerator key is used. This explains why the accelerator key for Item in the menu above will be disabled as expected but not the menu item in the submenu.
RESOLUTIONTo resolve the problem:
|
Additional reference words: 1.50 2.50 2.51 2.52 pop-up pop up
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |