Highlights or removes the highlight from a top-level (menu-bar) menu item.

BOOL HiliteMenuItem( 
   CMenu* pMenu, 
   UINT nIDHiliteItem, 
   UINT nHilite  


  • pMenu
    Identifies the top-level menu that contains the item to be highlighted.

  • nIDHiliteItem
    Specifies the menu item to be highlighted, depending on the value of the nHilite parameter.

  • nHilite
    Specifies whether the menu item is highlighted or the highlight is removed. It can be a combination of MF_HILITE or MF_UNHILITE with MF_BYCOMMAND or MF_BYPOSITION. The values can be combined using the bitwise OR operator. These values have the following meanings:

    • MF_BYCOMMAND   Interprets nIDHiliteItem as the menu-item ID (the default interpretation).

    • MF_BYPOSITION   Interprets nIDHiliteItem as the zero-based offset of the menu item.

    • MF_HILITE   Highlights the item. If this value is not given, the highlight is removed from the item.

    • MF_UNHILITE   Removes the highlight from the item.

Return Value

Specifies whether the menu item was highlighted. Nonzero if the item was highlighted; otherwise 0.


The MF_HILITE and MF_UNHILITE flags can be used only with this member function; they cannot be used with the CMenu::ModifyMenu member function.


Header: afxwin.h

See Also


CWnd Members


CWnd Class

Hierarchy Chart