You can change existing menus and menu items by using the ModifyMenu function. For example, you might need to change the text of a menu item. With ModifyMenu, you can enable or disable the item, check or clear it, or make it unavailable.
In the following example, the ModifyMenu function changes the text of the Water item to Wine. The example also changes the item's menu identifier.
ModifyMenu
(hMenu, IDM_WATER, MF_BYCOMMAND, IDM_WINE, "Wine");
When you use ModifyMenu, you are essentially telling Windows to replace an existing menu item with a new one. The third, fourth, and fifth ModifyMenu parameters specify the attributes of the new item.
For example, the following statement changes the item text from Wine to Cabernet. Although only the item's text is changing, the statement still specifies all the attributes of the item (in this case, just the menu identifier).
ModifyMenu
(hMenu, IDM_WINE, MF_BYCOMMAND, IDM_WINE, "Cabernet");
When you use ModifyMenu to change a menu item, you can also check or clear the item, enable or disable it, or make it unavailable.
The following example not only changes the Water command to Wine, it enables the command (if it is not enabled already), checks it, and changes its menu identifier:
ModifyMenu
(hMenu, IDM_WATER, MF_BYCOMMAND | MF_ENABLED | MF_CHECKED, IDM_WINE, "Wine");