Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CMenu::InsertMenu
◄CMenu► ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
BOOL InsertMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
const char FAR* lpNewItem = NULL );
BOOL InsertMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem,
const CBitmap* pBmp );
Parameter Description
<nPosition> Specifies the menu item before which the new menu item is
to be inserted. The interpretation of <nPosition> depends
on the setting of <nFlags>, as shown in the following
list:
nFlags Interpretation of <nPosition>
MF_BYCOMMAND Specifies that the parameter gives the
command ID of the existing menu item. This
is the default if neither MF_BYCOMMAND nor
MF_BYPOSITION is set.
MF_BYPOSITION Specifies that the parameter gives the
position of the existing menu item (the
first item is at position 0).
If <nPosition> is -1, the new menu item is
appended to the end of the menu.
<nFlags> Specifies how <nPosition> is interpreted and information
about the state of the new menu item when it is added to
the menu. For a list of the flags that may be set, see the
◄AppendMenu► member function. To specify more than one
value, use the bitwise-OR operator to combine them with the
MF_BYCOMMAND or MF_BYPOSITION flag.
<nIDNewItem> Specifies either the command ID of the new menu item or, if
<nFlags> is set to MF_POPUP, the menu handle (HMENU) of the
pop-up menu. <nIDNewItem> is ignored (not needed) if
<nFlags> is set to MF_SEPARATOR.
<lpNewItem> Specifies the content of the new menu item. The
interpretation of <lpNewItem> depends on the setting of
<nFlags> as shown below:
nFlags Interpretation of <lpNewItem>
MF_OWNERDRAW Contains an application-supplied 32-bit
value that the application can use to
maintain additional data associated with the
menu item. This 32-bit value is available to
the application when it processes
◄WM_MEASUREITEM► and ◄WM_DRAWITEM►
messages.
MF_STRING Contains a long pointer to a null-terminated
string. This is the default interpretation.
The <lpNewItem> parameter is ignored (not needed) if
<nFlags> is set to MF_SEPARATOR.
<pBmp> Points to a CBitmap object that will be used as the menu
item.
Remarks
Inserts a new menu item at the position specified by <nPosition> and
moves other items down the menu. The application can specify the state
of the menu item by setting values in <nFlags>.
Whenever a menu that resides in a window is changed (whether or not the
window is displayed), the application should call CWnd::DrawMenuBar.
When <nIDNewItem> specifies a pop-up menu, it becomes part of the menu
in which it is inserted. If that menu is destroyed, the inserted menu
will also be destroyed. An inserted menu should be detached from a CMenu
object to avoid conflict.
Return Value
TRUE if the function is successful; otherwise FALSE.
See Also
◄CMenu::AppendMenu►, ◄CWnd::DrawMenuBar►, ◄CMenu::SetMenuItemBitmaps►,
◄CMenu::Detach►, ◄CMenu::~CMenu►, ◄::InsertMenu►
-♦-