Export (0) Print
Expand All
3 out of 7 rated this helpful - Rate this topic

GetMenuItemInfo function

Retrieves information about a menu item.

Syntax


BOOL WINAPI GetMenuItemInfo(
  _In_     HMENU hMenu,
  _In_     UINT uItem,
  _In_     BOOL fByPosition,
  _Inout_  LPMENUITEMINFO lpmii
);

Parameters

hMenu [in]

Type: HMENU

A handle to the menu that contains the menu item.

uItem [in]

Type: UINT

The identifier or position of the menu item to get information about. The meaning of this parameter depends on the value of fByPosition.

fByPosition [in]

Type: BOOL

The meaning of uItem. If this parameter is FALSE, uItem is a menu item identifier. Otherwise, it is a menu item position. See Accessing Menu Items Programmatically for more information.

lpmii [in, out]

Type: LPMENUITEMINFO

A pointer to a MENUITEMINFO structure that specifies the information to retrieve and receives information about the menu item. Note that you must set the cbSize member to sizeof(MENUITEMINFO) before calling this function.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, use the GetLastError function.

Remarks

To retrieve a menu item of type MFT_STRING, first find the size of the string by setting the dwTypeData member of MENUITEMINFO to NULL and then calling GetMenuItemInfo. The value of cch+1 is the size needed. Then allocate a buffer of this size, place the pointer to the buffer in dwTypeData, increment cch by one, and then call GetMenuItemInfo once again to fill the buffer with the string.

If the retrieved menu item is of some other type, then GetMenuItemInfo sets the dwTypeData member to a value whose type is specified by the fTypefType member and sets cch to 0.

Examples

For an example, see Example of Owner-Drawn Menu Items.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

GetMenuItemInfoW (Unicode) and GetMenuItemInfoA (ANSI)

See also

Reference
SetMenuItemInfo
Conceptual
Menus

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.