Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How change menu item to checked or unchecked?

Tags:

c++

winapi

Have menu with some item, need change it to MF_CHECKED or MF_UNCHECKED.
And how to check up what item of menu is checked now?

like image 630
Oleh Avatar asked Oct 20 '13 12:10

Oleh


2 Answers

You can retrieve the check state among other information by calling GetMenuItemInfo. It fills a MENUITEMINFO structure. It's fState member will have the MFS_CHECKED flag set, if the menu item is checked.

To modify the check state of a menu item you call SetMenuItemInfo. There is also a utility function CheckMenuItem. The docs state that this API call may not be available in versions after Windows 2000. However, it still is.

like image 149
IInspectable Avatar answered Nov 04 '22 15:11

IInspectable


Just keeping the state of the menu in your own variables is the straight-forward solution. But you can use GetMenuItemInfo() to retrieve the state of a menu item, MENUITEMINFO.fState field.

like image 38
Hans Passant Avatar answered Nov 04 '22 14:11

Hans Passant