GetMenuState

Syntax

WORD GetMenuState(hMenu,wId,wFlags)

This function obtains the number of items in the pop-up menu associated with the menu item specified by the wId parameter if the hMenu parameter identifies a menu with an associated pop-up menu. If hMenu identifies a pop-up menu, this function obtains the status of the menu item associated with wId.

Parameter Type/Description  
hMenu HMENU Identifies the menu.  
wId WORD Specifies the menu-item ID.  
wFlags WORD Specifies the nature of the wId parameter. If the wFlags parameter contains MF_BYPOSITION, wId specifies a (zero-based) relative position; if wFlags contains MF_BYCOMMAND, wId specifies the item ID.  

Return Value

The return value specifies the outcome of the function. It is –1 if the specified item does not exist. If the menu itself does not exist, a fatal exit occurs. If wId identifies a pop-up menu, the return value contains the number of items in the pop-up menu in its high-order byte, and the menu flags associated with the pop-up menu in its low-order byte; otherwise, it is a mask (Boolean OR) of the values from the following list (this mask describes the status of the menu item that wId identifies):

Value Meaning  
MF_CHECKED Checkmark is placed next to item (pop-up menus only).  
MF_DISABLED Item is disabled.  
MF_ENABLED Item is enabled.  
MF_GRAYED Item is disabled and grayed.  
MF_MENUBARBREAK Same as MF_MENUBREAK, except for pop-up menus where the new column is separated from the old column by a vertical dividing line.  
MF_MENUBREAK Item is placed on a new line (static menus) or in a new column (pop-up menus) without separating columns.  
MF_SEPARATOR Horizontal dividing line is drawn (pop-up menus only). This line cannot be enabled, checked, grayed, or highlighted. The lpNewItem and wIDNewItem parameters are ignored.  
MF_UNCHECKED Checkmark is not placed next to item (default).