BOOL AppendMenu( UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL );
BOOL AppendMenu( UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp );
Return Value
Nonzero if the function is successful; otherwise 0.
Parameters
nFlags
Specifies information about the state of the new menu item when it is added to the menu. It consists of one or more of the values listed in the Remarks section.
nIDNewItem
Specifies either the command ID of the new menu item or, if nFlags is set to MF_POPUP, the menu handle (HMENU) of a pop-up menu. The nIDNewItem parameter is ignored (not needed) if nFlags is set to MF_SEPARATOR.
lpszNewItem
Specifies the content of the new menu item. The nFlags parameter is used to interpret lpszNewItem in the following way:
nFlags | Interpretation of lpszNewItem |
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. The value is stored in the itemData member of the structure supplied with those messages. |
MF_STRING | Contains a pointer to a null-terminated string. This is the default interpretation. |
MF_SEPARATOR | The lpszNewItem parameter is ignored (not needed). |
pBmp
Points to a CBitmap object that will be used as the menu item.
Remarks
Appends a new item to the end of a menu. The application can specify the state of the menu item by setting values in nFlags. When nIDNewItem specifies a pop-up menu, it becomes part of the menu to which it is appended. If that menu is destroyed, the appended menu will also be destroyed. An appended menu should be detached from a CMenu object to avoid conflict. Note that MF_STRING and MF_OWNERDRAW are not valid for the bitmap version of AppendMenu.
The following list describes the flags that may be set in nFlags:
Each of the following groups lists flags that are mutually exclusive and cannot be used together:
Whenever a menu that resides in a window is changed (whether or not the window is displayed), the application should call CWnd::DrawMenuBar.
Example
See the example for CMenu::CreateMenu.
CMenu Overview | Class Members | Hierarchy Chart
See Also CWnd::DrawMenuBar, CMenu::InsertMenu, CMenu::RemoveMenu, CMenu::SetMenuItemBitmaps, CMenu::Detach, ::AppendMenu