7.5.5 Deleting Menu Items

You can remove menu items and any pop-up menus associated with those items by using the DeleteMenu function. DeleteMenu permanently removes the specified item from the specified menu and moves subsequent items up to fill the gap.

DeleteMenu(hFruitMenu,  /* menu handle                     */
    1,                  /* deletes second item             */
    MF_BYPOSITION);     /* specifies item by menu position */

This example deletes the Fruit menu's second item. Windows moves any subsequent items up to fill the gap.

The following example deletes the same item, but specifies it by its menu identifier rather than by its position on the menu:

DeleteMenu(hFruitMenu,  /* menu handle                       */
    IDM_ORANGES,        /* deletes Oranges item              */
    MF_BYCOMMAND);      /* specifies item by menu identifier */