在登陆以前,让所有的菜单(pop-up类型)都灰色显示,程序中如何实现?

解决方案 »

  1.   

    EnableMenuItem Function--------------------------------------------------------------------------------The EnableMenuItem function enables, disables, or grays the specified menu item. SyntaxBOOL EnableMenuItem(          HMENU hMenu,
        UINT uIDEnableItem,
        UINT uEnable
    );
    ParametershMenu
    [in] Handle to the menu. 
    uIDEnableItem
    [in] 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
    [in] Controls 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. 
    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 ValueThe 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 is -1.
      

  2.   

    谢谢楼上,你没有注意到我说的是pop-up菜单,参数uIDEnableItem是什么?
      

  3.   

    CMenu m_menuPop;
    m_menuPopup.LoadMenu(IDR_***);
    m_menuPopup.GetSubMenu(0)->EnableMenuItem(ID_***,MF_DISABLED | MF_GRAYED);
      

  4.   

    在WIZARD里面给你要灰化的ID(比如ID_FILE_OPEN)添加一个ON_UPDATE_COMMAND_UI响应函数
    这个是系统自动生成的,然后再函数体内加入如下:
    就可以了,如果要给MENU灰化,在初始化时将m_bAutoMenuEnable = FALSE;添加到构造函数里.
    void CMainFrame::OnUpdateHotkeyAddstation(CCmdUI* pCmdUI) 
    {
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(FALSE);
    }