I have an old MFC app, and I am trying to disable menu items.
我有一个旧的MFC应用程序,我试图禁用菜单项。
I have a menu with a typical sort of structure:
我有一个典型的结构菜单:
File
- Open
- Save
- Close
Edit
- Cut
- Copy
- Paste
Using the following command:
使用以下命令:
EnableMenuItem(hMenu,ID_FILE, MF_BYCOMMAND | MF_GRAYED);
I can gray out menu commands of the top level menu items. However, if I do
我可以使*菜单项的菜单命令变灰。但是,如果我这样做
EnableMenuItem(hMenu,ID_PASTE, MF_BYCOMMAND | MF_GRAYED);
I cannot gray out any of the sub menu items. If I get the submenu handle and pass that to EnableMenuItem
, it does me no good. Nor does it help if I use SetMenuItemInfo
either
我无法使任何子菜单项变灰。如果我得到子菜单句柄并将其传递给EnableMenuItem,那对我没有好处。如果我也使用SetMenuItemInfo也没有帮助
Any ideas on how to disable sub-menu items? Are there any gotchas with the EnableMenuItem function?
有关如何禁用子菜单项的任何想法? EnableMenuItem函数有任何问题吗?
1 个解决方案
#1
0
According to MSDN you need to call DrawMenuBar() to get the UI to reflect changes to the menu state.
根据MSDN,您需要调用DrawMenuBar()来获取UI以反映菜单状态的更改。
#1
0
According to MSDN you need to call DrawMenuBar() to get the UI to reflect changes to the menu state.
根据MSDN,您需要调用DrawMenuBar()来获取UI以反映菜单状态的更改。