菜单项禁用后的启用

popofish2002 2004-09-04 10:43:30
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->EnableMenuItem(ID_FILE_NEW, MF_DISABLED);//不行么

CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(3);
submenu->EnableMenuItem(ID_ASD, MF_ENABLED);//不行么

不能禁用和启用
是主框架的菜单,我在其他菜单项消息处理中做上述处理,没有效果
...全文
108 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
TieShou 2004-09-04
  • 打赏
  • 举报
回复
给你个帮助里面的例子,你看看

// This example deletes the leftmost popup menu or leftmost
// popup menu item from the application's main window.
CWnd* pMain = AfxGetMainWnd();

// The main window _can_ be NULL, so this code
// doesn't ASSERT and actually tests.
if (pMain != NULL)
{
// Get the main window's menu
CMenu* pMenu = pMain->GetMenu();

// If there is a menu and it has items, we'll
// delete the first one.
if (pMenu != NULL && pMenu->GetMenuItemCount() > 0)
{
pMenu->DeleteMenu(0, MF_BYPOSITION);
// force a redraw of the menu bar
pMain->DrawMenuBar();
}

// No need to delete pMenu because it is an MFC
// temporary object.
}
李_军 2004-09-04
  • 打赏
  • 举报
回复
要在oncommandUI中写才有用
popofish2002 2004-09-04
  • 打赏
  • 举报
回复
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
//msdn这段代码贴上去也没用么
popofish2002 2004-09-04
  • 打赏
  • 举报
回复
MF_BYCOMMAND or MF_BYPOSITION都用过了,没用么
TieShou 2004-09-04
  • 打赏
  • 举报
回复
submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED);
你要指定是根据Command还是Position来禁用和启用,自己好好看看帮助!

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧