GetMenuItemID

2.x

  UINT GetMenuItemID(hmenu, pos)    
  HMENU hmenu; /* handle of menu, */  
  int pos; /* position of menu item */

The GetMenuItemID function retrieves the identifier for a menu item located at the given position.

Parameters

hmenu

Identifies the pop-up menu that contains the item whose identifier is to be retrieved.

pos

Specifies the zero-based position of the menu item whose identifier is to be retrieved.

Return Value

The return value specifies the identifier of the pop-up menu item if the function is successful. If the hmenu parameter is NULL or if the specified item is a pop-up menu (as opposed to an item within the pop-up menu), the return value is –1. If the pos parameter corresponds to a SEPARATOR menu item, the return value is zero.

Example

The following example initializes the items in a pop-up menu:

WORD wCount;
WORD wItem;
WORD wID;

case WM_INITMENUPOPUP:
    wCount = GetMenuItemCount((HMENU) wParam);
    for (wItem = 0; wItem < wCount; wItem++) {
        wID = GetMenuItemID((HMENU) wParam, wItem);
        .
        . /* Initialize menu items. */
        .
    }
    break;

See Also

GetMenu, GetMenuItemCount, GetSubMenu