如何检查弹出菜单项?
using CMenu::CheckMenuItem
See the example in MSDN .
在上下文菜单的情况下,使用AppendMenu()函数向菜单添加项目时使用MF_CHECKED样式。
When you create a popup menu entry there is no command number and you can only use MF_BYPOSITION parameter.
For example if you have menu created with
HMenu = CreateMenu();
And a Menu entry "Edition" where you have "Select..." with 3 choices :
HPopSubMenuSelect = CreatePopupMenu();
AppendMenu(HPopSubMenuSelect, MF_STRING, 20, "All");
AppendMenu(HPopSubMenuSelect, MF_STRING, 21, "Word");
AppendMenu(HPopSubMenuSelect, MF_STRING, 22, "Nothing");
HPopMenuEdition = CreatePopupMenu();
AppendMenu(HPopMenuEdition, MF_STRING | MF_POPUP , HPopSubMenuSelect,"Select...");
AppendMenu(HMenu, MF_STRING | MF_POPUP , HPopMenuEdition, "Edition");
Then to check this you must call
CheckMenuItem(HPopMenuEdition, 1, MF_BYPOSITION | MF_CHECKED);
// Or for uncheck
// CheckMenuItem(HPopMenuEdition, 1, MF_BYPOSITION | MF_UNCHECKED);
Greetings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.