CheckMenuItem

  DWORD CheckMenuItem(hmenu, idCheckItem, fuFlags)    
  HMENU hmenu; /* handle of menu */
  UINT idCheckItem; /* menu-item to check or uncheck */
  UINT fuFlags; /* menu-item flags */

The CheckMenuItem function sets the state of the given menu item's check mark attribute to either checked or unchecked.

Parameters

hmenu

Identifies the menu.

idCheckItem

Specifies the menu item whose check mark attribute is to be set, as determined by the fuFlags parameter.

fuFlags

Specifies flags that control the interpretation of the idCheckItem parameter and the state of the menu item's check mark attribute. This parameter can be a combination of either MF_BYCOMMAND or MF_BYPOSITION, and MF_CHECKED or MF_UNCHECKED.

Value Meaning

MF_BYCOMMAND Specifies that the idCheckItem parameter gives the identifier of the menu item.
MF_BYPOSITION Specifies that the idCheckItem parameter gives the zero-based relative position of the menu item.
MF_CHECKED Sets the check mark attribute to the checked state.
MF_UNCHECKED Sets the check mark attribute to the unchecked state.

Return Value

The return value specifies the previous state of the menu item. It is either MF_CHECKED or MF_UNCHECKED. The return value is 0xFFFFFFFF if the menu item does not exist.

Comments

An item in a menu bar cannot have a check mark.

The idCheckItem parameter can identify a pop-up item or a command item. For a pop-up item, the idCheckItem parameter must specify the position of the item, since a pop-up item does not have an identifier. For a command item, the idCheckItem parameter can specify either the item's position or its identifier.

See Also

EnableMenuItem, GetMenuCheckMarkDimensions, GetMenuItemID, SetMenuItemBitmaps