checking menu items

How do you check a menu item in Visual Studio.Net 2003 using MFC


Answer this question

checking menu items

  • habnix

    Lookup SetMenuItemInfo, MENUITEMINFO, and MFS_CHECKED on MSDN.

    Nathan87 wrote:
    How do you check a menu item in Visual Studio.Net 2003 using MFC



  • GTH

    The MFC way is not to manipulate the menu directly. There is a so called OnCommand Handler and OnUpdateCommand handelr technique.

    In the OnUpdate Handler of your command just use pCmdUI->SetCheck(m_bMyState);



  • RoseyA

    Thanks guys for all the help. I tried both the ways you suggested but neither one worked, but they did get me going in the right direction and I found that this way did work:

    CWnd::OnContextMenu()...

    CMenu menu;
    menu.LoadMenu(IDR_POPUP_MENU);

    CMenu *popupMenu = menu.GetSubMenu(0);
    popupMenu->CheckMenuItem(ID_DOCKED, MF_BYCOMMAND | (isDocked MF_CHECKED : MF_UNCHECKED));


    Thanks again for all the help.

  • checking menu items