默认情况下启用或禁用菜单项.为什么? [英] Menu items are being enabled or disabled by default. Why?

查看:33
本文介绍了默认情况下启用或禁用菜单项.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些遗留代码,出于某种原因,菜单项在启动时被启用或禁用.我的问题是,如何?有没有办法在不调用 EnableMenuItem() 函数的情况下做到这一点?有没有办法让 MFC 做与资源设置所说的相反的事情?

I have some legacy code and for some reason, menu items are being enabled or disabled on launch. My question is, how? Is there any way to do this without calling the EnableMenuItem() function? Is there a way for MFC to do the opposite from what the resource settings say?

当最后一个子窗口关闭时,我也不知道为什么在 SDI 中禁用或重新启用当前的.这可能是因为我对框架的理解不够好,我以为我已经通读了所有文档 此处.

I'm also at a loss as to why the current ones are being disabled or reenabled in a SDI when the last child window has closed. This is probably due to me not understanding the framework well enough and I thought I've read through all of the docs here.

推荐答案

使用 MFC,如果没有 ON_UPDATE_COMMAND_UI 处理程序也不是 菜单项的 ON_COMMAND 处理程序 -- 根据 这篇 MSDN 文章,

With MFC, menu items could be disabled if there is neither a ON_UPDATE_COMMAND_UI handler nor a ON_COMMAND handler for the menu item -- according to this MSDN article,

如果框架在执行过程中没有找到 ON_UPDATE_COMMAND_UI 条目命令路由,它会自动启用用户界面对象,如果某处有一个具有相同命令 ID 的 ON_COMMAND 条目.否则,它将禁用用户界面对象...可以禁用用户界面对象的默认禁用.有关详细信息,请参阅 MFC 参考中 CFrameWnd 类的 m_bAutoMenuEnable 成员

If the framework does not find an ON_UPDATE_COMMAND_UI entry during command routing, it automatically enables the user-interface object if there is an ON_COMMAND entry somewhere with the same command ID. Otherwise, it disables the user-interface object ... It is possible to disable the default disabling of user-interface objects. For more information, see the m_bAutoMenuEnable member of class CFrameWnd in the MFC Reference

[这适用于菜单项和工具栏项]

[this applies to menu-items and toolbar-items]

这篇关于默认情况下启用或禁用菜单项.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆