Menu items are being enabled or disabled by default. Why?(默认情况下启用或禁用菜单项.为什么?)
问题描述
我有一些遗留代码,出于某种原因,菜单项在启动时被启用或禁用.我的问题是,如何?有没有办法在不调用 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]
这篇关于默认情况下启用或禁用菜单项.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:默认情况下启用或禁用菜单项.为什么?


基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 我有静态或动态 boost 库吗? 2021-01-01