2 out of 5 rated this helpful - Rate this topic

GetMenuItemInfo function

Applies to: desktop apps only

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

Minimum supported server

Windows 2000 Server

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

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ