Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Popup Menu - Check Menu Item

Popup Menu - Check Menu Item

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JBAK_CP
    wrote on last edited by
    #1

    Hi, I have a dialog box with a pop-up menu and one of the menu entry in there has the 'Checked' property set to true (as default). Now during the execution of my program, I would like to un-check the check mark next to this menu item, but I can't seem to be able to accomplish this, the check-mark seems to be there always. Debugging through the code, it seems to execute the correct statements, but the GUI does not seem to get updated. Any help would be greatly apperciated. VS2005, C++ (MFC) Code:

    CMenu menuTst;
    VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));
    CMenu* pPopupTest = menuTst.GetSubMenu(0);

    UINT state = pPopupTest->GetMenuState(ID\_OPEN\_LOGFILE, MF\_BYCOMMAND);
    
         ASSERT(state != 0xFFFFFFFF);
    
    if (state & MF\_CHECKED)
           pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_UNCHECKED | MF\_BYCOMMAND);
        else
           pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_CHECKED | MF\_BYCOMMAND);
    
    S 1 Reply Last reply
    0
    • J JBAK_CP

      Hi, I have a dialog box with a pop-up menu and one of the menu entry in there has the 'Checked' property set to true (as default). Now during the execution of my program, I would like to un-check the check mark next to this menu item, but I can't seem to be able to accomplish this, the check-mark seems to be there always. Debugging through the code, it seems to execute the correct statements, but the GUI does not seem to get updated. Any help would be greatly apperciated. VS2005, C++ (MFC) Code:

      CMenu menuTst;
      VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));
      CMenu* pPopupTest = menuTst.GetSubMenu(0);

      UINT state = pPopupTest->GetMenuState(ID\_OPEN\_LOGFILE, MF\_BYCOMMAND);
      
           ASSERT(state != 0xFFFFFFFF);
      
      if (state & MF\_CHECKED)
             pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_UNCHECKED | MF\_BYCOMMAND);
          else
             pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_CHECKED | MF\_BYCOMMAND);
      
      S Offline
      S Offline
      sudhir_Kumar
      wrote on last edited by
      #2

      You are loading menu locally in the function that,s why its not affecting the changes. make CMenu menuTst; member of class and load (VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));) somewhere like initdialog();

      Sudhir Kumar

      J 1 Reply Last reply
      0
      • S sudhir_Kumar

        You are loading menu locally in the function that,s why its not affecting the changes. make CMenu menuTst; member of class and load (VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));) somewhere like initdialog();

        Sudhir Kumar

        J Offline
        J Offline
        JBAK_CP
        wrote on last edited by
        #3

        Hmm..unfortunately making the CMenu variable member of the class didn't seem to work either. I tried adding an ON_UPDATE_COMMAND_UI function for my menu item to try it in there, with no success!

        void CTestDialog::OnUpdateOpenLogfile(CCmdUI *pCmdUI)
        {

        //pCmdUI->SetCheck(1);
            pCmdUI->SetCheck(0);
        

        }

        H 1 Reply Last reply
        0
        • J JBAK_CP

          Hmm..unfortunately making the CMenu variable member of the class didn't seem to work either. I tried adding an ON_UPDATE_COMMAND_UI function for my menu item to try it in there, with no success!

          void CTestDialog::OnUpdateOpenLogfile(CCmdUI *pCmdUI)
          {

          //pCmdUI->SetCheck(1);
              pCmdUI->SetCheck(0);
          

          }

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Why CMenu doesnt work?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups