GetMenuDefaultItem function

Determines the default menu item on the specified menu.

Syntax

UINT GetMenuDefaultItem(
  HMENU hMenu,
  UINT  fByPos,
  UINT  gmdiFlags
);

Parameters

hMenu

Type: HMENU

A handle to the menu for which to retrieve the default menu item.

fByPos

Type: UINT

Indicates whether to retrieve the menu item's identifier or its position. If this parameter is FALSE, the identifier is returned. Otherwise, the position is returned.

gmdiFlags

Type: UINT

Indicates how the function should search for menu items. This parameter can be zero or more of the following values.

Value Meaning
GMDI_GOINTOPOPUPS
0x0002L
If the default item is one that opens a submenu, the function is to search recursively in the corresponding submenu. If the submenu has no default item, the return value identifies the item that opens the submenu. By default, the function returns the first default item on the specified menu, regardless of whether it is an item that opens a submenu.
GMDI_USEDISABLED
0x0001L
The function is to return a default item, even if it is disabled. By default, the function skips disabled or grayed items.

Return Value

Type: UINT

If the function succeeds, the return value is the identifier or position of the menu item.

If the function fails, the return value is -1. To get extended error information, call GetLastError.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See Also

Conceptual

Menus

Reference

SetMenuDefaultItem