CheckMenuItem

Syntax

BOOL CheckMenuItem(hMenu,wIDCheckItem,wCheck)

This function places checkmarks next to or removes checkmarks from menu items in the pop-up menu specified by the hMenu parameter. The wIDCheckItem parameter specifies the item to be modified.

Parameter Type/Description  

hMenu HMENU Identifies the menu.  
wIDCheckItem WORD Specifies the menu item to be checked.  
wCheck WORD Specifies how to check the menu item and how to determine the item's position in the menu. The wCheck parameter can be a combination of the MF_CHECKED or MF_UNCHECKED with MF_BYPOSITION or MF_BYCOMMAND flags. These flags can be combined by using the bitwise OR operator. They have the following meanings:  
  Value Meaning
  MF_BYCOMMAND Specifies that the wIDCheckItem parameter gives the menu-item ID (MF_BYCOMMAND is the default).
  MF_BYPOSITION Specifies that the wIDCheckItem parameter gives the position of the menu item (the first item is at position zero).
  MF_CHECKED Adds checkmark.
  MF_UNCHECKED Removes checkmark.

Return Value

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

Comments

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

Top-level menu items cannot be checked.

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