CMenu *m_sysMenu;
        CMenu *submenu; 
        m_sysMenu = GetMenu();
        submenu=m_sysMenu-> GetSubMenu(1);
        submenu->EnableMenuItem(ID_BASE_CLERK,MF_ENABLED);
这样可以吗?可是运行到submenu=m_sysMenu-> GetSubMenu(1);就出错了。

解决方案 »

  1.   

    我做了一个登陆界面,我在登陆对话框的OnOk()事件里面加入了以上代码,想在用户登陆以后可以使用菜单里面的功能。可是上面的代码出错:((
      

  2.   

    CMenu *pSubMenu = GetMenu()->GetSubMenu(0);
    pSubMenu->EnableMenuItem(ID, MF_ENABLED);
      

  3.   

    以下是msdn中的一段话:Enables, disables, or dims a menu item. The CreateMenu, InsertMenu, ModifyMenu, and LoadMenuIndirect member functions can also set the state (enabled, disabled, or dimmed) of a menu item.Using the MF_BYPOSITION value requires an application to use the correct CMenu. If the CMenu of the menu bar is used, a top-level menu item (an item in the menu bar) is affected. To set the state of an item in a pop-up or nested pop-up menu by position, an application must specify the CMenu of the pop-up menu. When an application specifies the MF_BYCOMMAND flag, Windows checks all pop-up menu items that are subordinate to the CMenu; therefore, unless duplicate menu items are present, using the CMenu of the menu bar is sufficient.不知对你检查是否有用!
      

  4.   

    你登陆框是在哪里弹出的?确认这时候MainFrame的menu已经建好了。还有,第一个菜单是0,而不是1
      

  5.   

    禁止
    CMenu* pMenu = this->GetSystemMenu(FALSE);
    pMenu->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
    允许
    CMenu* pMenu = this->GetSystemMenu(FALSE);
    pMenu->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
      

  6.   

    你的代码还需要制订MF_BYPOSITION或者MF_BYCOMMAND
      

  7.   

    你的代码还需要制订MF_BYPOSITION或者MF_BYCOMMAND?
    是什么意思阿?