The GetMenuItemInfo function retrieves information about a menu item.
Syntax
BOOL GetMenuItemInfo(
HMENU hMenu,
UINT uItem,
BOOL fByPosition,
LPMENUITEMINFO lpmii
);
Parameters
- hMenu
-
[in] Handle to the menu that contains the menu item.
- uItem
-
[in] Identifier or position of the menu item to get information about. The meaning of this parameter depends on the value of fByPosition.
- fByPosition
-
[in] Specifies the meaning of uItem. If this parameter is FALSE, uItem is a menu item identifier. Otherwise, it is a menu item position. See Menu Programming Considerations for more information.
- lpmii
-
[in, out] Pointer to a MENUITEMINFO structure that specifies the information to retrieve and receives information about the menu item. Note that you must set MENUITEMINFO.cbSize to sizeof(MENUITEMINFO) before calling this function.
Return Value
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.
Windows 98/Me and Windows 2000/XP: dwTypeData and cch are used with MIIM_STRING.
Windows 95/98/Me: GetMenuItemInfoW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
Example
For an example, see Example of Owner-Drawn Menu Items.
Function Information
| Minimum DLL Version | user32.dll |
|---|
| Header | Declared in Winuser.h, include Windows.h |
|---|
| Import library | User32.lib |
|---|
| Minimum operating systems |
Windows 95, Windows NT 4.0 |
|---|
| Unicode | Implemented as
ANSI and Unicode versions. |
|---|
See Also