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::ModifyMenu
◄CMenu► ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
BOOL ModifyMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem = 0,
const char FAR* lpNewItem = NULL);
BOOL ModifyMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem,
const CBitmap* pBmp);
Parameter Description
<nPosition> Specifies the menu item to be changed. 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).
<nFlags> Specifies how <nPosition> is interpreted and gives
information about the changes to be made to the menu item.
For a list of flags that may be set, see the ◄AppendMenu►
member function.
<nIDNewItem> Specifies either the command ID of the modified 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.
<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
MF_MEASUREITEM and MF_DRAWITEM.
MF_STRING Contains a long pointer to a null-terminated
string or to a CString.
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
Changes an existing menu item at the position specified by <nPosition>.
The application specifies the new state of the menu item by setting
values in <nFlags>. If this function replaces a pop-up menu associated
with the menu item, it destroys the old pop-up menu and frees the memory
used by the pop-up menu.
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.
Whenever a menu that resides in a window is changed (whether or not the
window is displayed), the application should call CWnd::DrawMenuBar. To
change the attributes of existing menu items, it is much faster to use
the CheckMenuItem and EnableMenuItem functions.
Return Value
TRUE if the function is successful; otherwise FALSE.
See Also
◄CMenu::AppendMenu►, ◄CMenu::InsertMenu►, ◄CMenu::CheckMenuItem►,
◄CWnd::DrawMenuBar►, ◄CMenu::EnableMenuItem►,
◄CMenu::SetMenuItemBitmaps►, ◄CMenu::Detach►, ◄CMenu::~CMenu►,
◄::ModifyMenu►
-♦-