Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function inserts a new menu item into a menu, moving other items down the menu.

Syntax

BOOL InsertMenu(
  HMENU 
hMenu, 
  UINT 
uPosition, 
  UINT 
uFlags, 
  UINT 
uIDNewItem, 
  LPCTSTR 
lpNewItem 
); 

Parameters

hMenu

[in] Handle to the menu to be changed.

uPosition

[in] The menu item before which the new menu item is to be inserted, as determined by the uFlagsparameter. If uPositionis 0xFFFFFFFF, the new menu item is appended to the end of the menu.

uFlags

[in] Specifies flags to control the interpretation of the uPositionparameter and the content, appearance, and behavior of the new menu item. This parameter must be a combination of one of the required constants MF_BYCOMMAND or MF_BYPOSITION and at least one of the other constants listed in Menus Constants.

If this parameter includes the MF_SEPARATOR constant, InsertMenuignores the values of the lpNewItemand uIDNewItemparameters. If this parameter includes the MF_STRING constant, the lpNewItemparameter points to the string.

uIDNewItem

[in] Either the identifier of the new menu item or, if the uFlagsparameter has the MF_POPUP constant set, the handle to the drop-down menu or submenu.

lpNewItem

[in] Long pointer to the content of the new menu item. If uFlagsincludes the MF_STRING constant, lpNewItempoints to a null-terminated string (the default). If uFlagsincludes the MF_OWNERDRAW constant, lpNewItempoints to a 32-bit value that can be used to maintain additional data related to the menu item.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

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

Windows CE 1.0 and 1.01 do not support cascading menus. If you are using Windows CE 1.0 or 1.01, you cannot insert an MF_POPUP menu into another pop-up menu. If using Windows CE 2.0 or later, you can.

Requirements

Header winuser.h
Library Menu.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also