Share via


CMenu::GetDefaultItem

Determines the default menu item on the specified menu.

UINT GetDefaultItem( 
   UINT gmdiFlags, 
   BOOL fByPos = FALSE  
);

Parameters

  • gmdiFlags
    Value specifying how the function searches for menu items. This parameter can be none, one, or a combination of the following values:

    Value

    Meaning

    GMDI_GOINTOPOPUPS

    Specifies that, if the default item is one that opens a submenu, the function is to search in the corresponding submenu recursively. 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

    Specifies that the function is to return a default item, even if it is disabled.

    By default, the function skips disabled or grayed items.

  • fByPos
    Value specifying 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.

Return Value

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.

Remarks

This member function implements the behavior of the Win32 function GetMenuDefaultItem, as described in the Windows SDK.

Example

See the example for CMenu::InsertMenu.

Requirements

Header: afxwin.h

See Also

Reference

CMenu Class

Hierarchy Chart

CMenu::SetDefaultItem