CMenu::GetMenuState

UINT GetMenuState( UINT nID, UINT nFlags ) const;

Return Value

The value 0xFFFFFFFF if the specified item does not exist. If nId identifies a pop-up menu, the high-order byte contains the number of items in the pop-up menu and the low-order byte contains the menu flags associated with the pop-up menu. Otherwise the return value is a mask (Boolean OR) of the values from the following list (this mask describes the status of the menu item that nId identifies):

Parameters

nID

Specifies the menu item ID, as determined by nFlags.

nFlags

Specifies the nature of nID. It can be one of the following values:

Remarks

Returns the status of the specified menu item or the number of items in a pop-up menu.

Example

// CMainFrame::OnToggleTestMenuItem() is a menu command handler for 
// "Test" menu item (whose resource id is ID_HELP_TEST). It toggles 
// the checked or unchecked state of the "Test" menu item.
// CMainFrame is a CFrameWnd-derived class.

void CMainFrame::OnToggleTestMenuItem() 
{
   // Get the popup menu which contains the "Test" menu item.
   CMenu* mmenu = GetMenu();
   CMenu* submenu = mmenu->GetSubMenu(3);

   // Check the state of the "Test" menu item. Check the menu item
   // if it is currently unchecked. Otherwise, uncheck the menu item
   // if it is not currently checked.
   UINT state = submenu->GetMenuState(ID_HELP_TEST, MF_BYCOMMAND);
   ASSERT(state != 0xFFFFFFFF);

   if (state & MF_CHECKED)
      submenu->CheckMenuItem(ID_HELP_TEST, MF_UNCHECKED | MF_BYCOMMAND);
   else
      submenu->CheckMenuItem(ID_HELP_TEST, MF_CHECKED | MF_BYCOMMAND);
}

CMenu OverviewClass MembersHierarchy Chart

See Also   ::GetMenuState, CMenu::CheckMenuItem, CMenu::EnableMenuItem