同上

解决方案 »

  1.   

    HMENU hMenu = LoadMenu(AfxGetApp()->m_hInstance ,MAKEINTRESOURCE(IDR_MAINMENU));
    HMENU hPopup = GetSubMenu(hMenu,0);
    SetForegroundWindow();
    EnableMenuItem(hMenu,ID_XXXXX,MF_GRAYED);
      

  2.   

    响应 command_ui加入 pUI->Enable(FALSE)
      

  3.   

    BOOL EnableMenuItem(
      HMENU hMenu,         // handle to menu
      UINT uIDEnableItem,  // menu item to enable, disable, or gray
      UINT uEnable         // menu item flags
    );
     
    Parameters
    hMenu 
    Handle to the menu. 
    uIDEnableItem 
    Specifies the menu item to be enabled, disabled, or grayed, as determined by the uEnable parameter. This parameter specifies an item in a menu bar, menu, or submenu. 
    uEnable 
    Specifies flags that control the interpretation of the uIDEnableItem parameter and indicate whether the menu item is enabled, disabled, or grayed. This parameter must be a combination of either MF_BYCOMMAND or MF_BYPOSITION and MF_ENABLED, MF_DISABLED, or MF_GRAYED. Value Meaning 
    MF_BYCOMMAND Indicates that uIDEnableItem gives the identifier of the menu item. If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified, the MF_BYCOMMAND flag is the default flag. 
    MF_BYPOSITION Indicates that uIDEnableItem gives the zero-based relative position of the menu item. 
    MF_DISABLED Indicates that the menu item is disabled, but not grayed, so it cannot be selected. 
    MF_ENABLED Indicates that the menu item is enabled and restored from a grayed state so that it can be selected. 
    MF_GRAYED Indicates that the menu item is disabled and grayed so that it cannot be selected. 
    Return Values
    The return value specifies the previous state of the menu item (it is either MF_DISABLED, MF_ENABLED, or MF_GRAYED). If the menu item does not exist, the return value 
      

  4.   

    点击VIEW,选择ClassWizard,在*View类中的OBJECT IDS中找到你的菜单ID,选中,在MESSAGE框中选中UPDATE COMMAND UI点击右边的Add Function,这样就在下面的Mweeage Function框中增加了一个消息更新函数,选中这个函数,再点击Edit Code在这个函数中增加代码
          pUI->Enable(FALSE);//可使菜单变灰
          pCmdUI->SetCheck(条件);//可使菜单打勾