CheckMenuItem

2.x

  BOOL CheckMenuItem(hmenu, idCheckItem, uCheck)    
  HMENU hmenu; /* handle of menu, */  
  UINT idCheckItem; /* menu-item identifier, */  
  UINT uCheck; /* check state and position */

The CheckMenuItem function selects (places a check mark next to) or clears (removes a check mark from) a specified menu item in the given pop-up menu.

Parameters

hmenu

Identifies the menu.

idCheckItem

Identifies the menu item to be selected or cleared.

uCheck

Specifies how to determine the position of the menu item (MF_BYCOMMAND or MF_BYPOSITION) and whether the item should be selected or cleared (MF_CHECKED or MF_UNCHECKED). This parameter can be a combination of these values, which can be combined by using the bitwise OR operator. The values are described as follows:

Value Meaning

MF_BYCOMMAND Specifies that the idCheckItem parameter gives the menu-item identifier (MF_BYCOMMAND is the default).
MF_BYPOSITION Specifies that the idCheckItem parameter gives the position of the menu item (the first item is at position zero).
MF_CHECKED Selects the item (adds check mark).
MF_UNCHECKED Clears the item (removes check mark).

Return Value

The return value specifies the previous state of the item—MF_CHECKED or MF_UNCHECKED—if the function is successful. The return value is –1 if the menu item does not exist.

Comments

The idCheckItem parameter may identify a pop-up menu item as well as a menu item. No special steps are required to select a pop-up menu item.

Top-level menu items cannot have a check.

A pop-up menu item should be selected by position since it does not have a menu-item identifier associated with it.

See Also

GetMenuState, SetMenuItemBitmaps