GetMenuItemCount

2.x

  int GetMenuItemCount(hmenu)    
  HMENU hmenu; /* handle of menu, */  

The GetMenuItemCount function determines the number of items in a pop-up or top-level menu.

Parameters

hmenu

Identifies the handle of the menu to be examined.

Return Value

The return value specifies the number of items in the menu if the function is successful. Otherwise, it is –1.

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, GetMenuItemID, GetSubMenu