InsertMenuItem Function

The InsertMenuItem function inserts a new menu item at the specified position in a menu.

Syntax

BOOL InsertMenuItem(      
    HMENU hMenu,     UINT uItem,     BOOL fByPosition,     LPCMENUITEMINFO lpmii );

Parameters

hMenu
[in] Handle to the menu in which the new menu item is inserted.
uItem
[in] Identifier or position of the menu item before which to insert the new item. The meaning of this parameter depends on the value of fByPosition.
fByPosition
[in] Value specifying 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] Pointer to a MENUITEMINFO structure that contains information about the new menu item.

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

The application must call the DrawMenuBar function whenever a menu changes, whether or not the menu is in a displayed window.

In order for keyboard accelerators to work with bitmap or owner-drawn menu items, the owner of the menu must process the WM_MENUCHAR message. See Owner-Drawn Menus and the WM_MENUCHAR Message for more information.

Windows 95/98/Me: InsertMenuItemW 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 Menu-Item Bitmaps.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 4.0
UnicodeImplemented as ANSI and Unicode versions.

See Also

Tags :


Community Content

Đonny
VB8 Declaration
Public Declare Auto Function InsertMenuItem Lib "user32.dll" (ByVal hMenu As Int32, ByVal uItem As Int32, ByVal fByPosition As Boolean, ByRef lpmii As MENUITEMINFO) As Int32

Page view tracker