Search code examples
c++visual-c++menumfcmdi

Disable main menu


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.


Solution

  • 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.