GetMenuDefaultItem function (winuser.h)

Determines the default menu item on the specified menu.

Syntax

UINT GetMenuDefaultItem(
  [in] HMENU hMenu,
  [in] UINT  fByPos,
  [in] UINT  gmdiFlags
);

Parameters

[in] hMenu

Type: HMENU

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

[in] 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.

[in] 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

Requirement Value
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
API set ext-ms-win-ntuser-menu-l1-1-0 (introduced in Windows 8)

See also

Conceptual

Menus

Reference

SetMenuDefaultItem