CMenu mainMenu;
mainMenu.LoadMenu(IDR_MENU_MAIN);
AfxGetMainWnd()->SetMenu(&mainMenu);
AfxGetMainWnd()->DrawMenuBar();
IDR_MENU_MAIN菜单构造如下:sub1,sub2,sub3为new的下拉菜单,sub4,5,6为test的下接菜单
new      test
 sub1     sub4
 sub2     sub5
 sub3     sub6
现在我要把test置为无效,即全部变灰,不能响应该其对应的command函数
或者令test子菜单变为不可见,要怎么做

解决方案 »

  1.   

    可以用 EnableMenuItem() 和 DeleteMenu()
    来实现
    具体的用法查下 MSDN 吧!
    上面说的蛮全的!
      

  2.   

    CMenu* mmenu = GetMenu();
    CMenu* submenu = mmenu->GetSubMenu(0);
    submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
      

  3.   

    http://www.moon-soft.com/program/doc/readelite9768.htm
      

  4.   

    EnableMenuItem(ID_???, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
    或者响应OnUpdate???消息
      

  5.   

    Example
    // The code fragment below shows how to disable (and gray out) the 
    // File\New menu item.
    // NOTE: m_bAutoMenuEnable is set to FALSE in the constructor of 
    // CMainFrame so no ON_UPDATE_COMMAND_UI or ON_COMMAND handlers are 
    // needed, and CMenu::EnableMenuItem() will work as expected.CMenu* mmenu = GetMenu();
    CMenu* submenu = mmenu->GetSubMenu(0);
    submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
      

  6.   

    http://www.vckbase.com/document/viewdoc/?id=185
      

  7.   

    GetMenu->EnableMenuItem(ID_TEST,MF_DISABLED)