中易网

vc中怎么disable菜单选项

答案:2  悬赏:60  
解决时间 2021-02-12 18:53
vc中怎么disable菜单选项
最佳答案
CMenu::EnableMenuItem

UINT EnableMenuItem( UINT nIDEnableItem,
UINT nEnable );

Return Value

Previous state (MF_DISABLED, MF_ENABLED, or MF_GRAYED)
or –1 if not valid.

Parameters

nIDEnableItem

Specifies the menu item to be enabled, as determined by
nEnable. This parameter can specify pop-up menu items as well as standard
menu items.

nEnable

Specifies the action to take. It can be a combination of
MF_DISABLED, MF_ENABLED, or MF_GRAYED, with
MF_BYCOMMAND or MF_BYPOSITION. These values can be combined by
using the bitwise OR operator. These values have the following meanings:

MF_BYCOMMAND Specifies that the parameter gives the command ID of
the existing menu item. This is the default.

MF_BYPOSITION Specifies that the parameter gives the position of
the existing menu item. The first item is at position 0.

MF_DISABLED Disables the menu item so that it cannot be selected
but does not dim it.

MF_ENABLED Enables the menu item so that it can be selected and
restores it from its dimmed state.

MF_GRAYED Disables the menu item so that it cannot be selected and
dims it.

Remarks

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.

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);

来自MSDN
全部回答
我不会~~~但还是要微笑~~~:)
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
生辉干果瓜籽店这个地址在什么地方,我要处理
家做炖牛肉怎么做好吃
我想在北京找一个伺候老人的我是男的
西安银泉纸业有限公司在哪里啊,我有事要去这
哪个网站能下到祖玛豪华版啊,要1920x10
魔兽世界连续十次扫雷怎么做
描写听到这个消息后觉得遭受打击后的句子
官扎营中街在什么地方啊,我要过去处理事情
二尖瓣狭窄是指瓣膜狭窄还是瓣口狭窄
脂肪对人体有什么作用?
请问2015年摩托车驾校考试安排时间怎么查?
premiere6.5怎么安装win7系统里
lady jane在韩国很红吗
甲午山地址在什么地方,想过去办事
批发商和经销商哪个利润大
推荐资讯
龙族视觉婚纱摄影机构地址在哪,我要去那里办
如何在word中与参考文献对应起来
麒麟区寥廓街道阿诗玛社区居民委员会地址有知
武汉大学小太阳心禾幼儿园我想知道这个在什么
生活就是( ) 补写比喻句。
有适合男人玩的地方吗
女朋友心里有阴影怎么办?
鑫垚家具窗帘地址在什么地方,想过去办事
显卡升级,,只是为了玩QQ飞车,,,不要太高
家庭用的台式电脑一般用多大的显示器比较适合
手撕老母鸡双沟店怎么去啊,有知道地址的么
深圳旧木材市场
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?