I have a menu that looks somewhat like the following,

enter image description here

When I open a particular dialog, I want to disable the whole menu. I realize that I can individually disable each menu item by using Update_Command_UIs, but that would mean adding event handlers for a 100 or more menu items. The menu is loaded initially with CMultiDocTemplate. Is there a way to do it by using the ID resource (IDR_MENU)?

Any help would be appreciated. Thank you.

有帮助吗?

解决方案 2

I used ,

CMenu* pMenu = AfxGetMainWnd()->GetMenu();
if(pMenu != NULL)
{
    for(UINT i = 0; i < pMenu->GetMenuItemCount (); ++i)
        pMenu->EnableMenuItem(i, MF_BYPOSITION | MF_DISABLED);
}

as mentioned in http://forums.codeguru.com/showthread.php?456136-Can-I-disable-menu-bar. It worked for me.

其他提示

In your mainframe class, m_wndMenuBar.EnableWindow(FALSE);? The main menu items won't be grayed out, but they're not selectable.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top