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. Simple menu question

Simple menu question

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
4 Posts 4 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.
  • M Offline
    M Offline
    masnu
    wrote on last edited by
    #1

    I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:

    void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
    {

    // Update menu
    pCmdUI->SetCheck( m_bShowPeakVoltage );

    }

    The menu item does not update, however. I'm I missing something? Thanks.

    V I M 3 Replies Last reply
    0
    • M masnu

      I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:

      void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
      {

      // Update menu
      pCmdUI->SetCheck( m_bShowPeakVoltage );

      }

      The menu item does not update, however. I'm I missing something? Thanks.

      V Offline
      V Offline
      vikas amin
      wrote on last edited by
      #2

      If u need it before creating use the flags MF_CHECKED You need to use DrawMenuBar() after you do any modification to the menu . The CheckMenuItem function sets the state of the specified menu item's check-mark attribute to either selected or clear. Good MSDN article http://msdn.microsoft.com/en-us/library/ms647558(VS.85).aspx[^]

      Vikas Amin

      My First Article on CP" Virtual Serail Port "[^]

      modified on Thursday, July 24, 2008 5:33 PM

      1 Reply Last reply
      0
      • M masnu

        I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:

        void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
        {

        // Update menu
        pCmdUI->SetCheck( m_bShowPeakVoltage );

        }

        The menu item does not update, however. I'm I missing something? Thanks.

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        I would suggest adding your command to a toolbar to see if that updates or not. I see your command is in a dialog. Is this a formview? If it is a modeless window, the command messages may not be routing there. Try adding the updateui handler to whatever is your CMainFrame (look in CMyApp::InitInstance to see what is being assigned to m_pMainWnd. Have a read / google about OnCmdMsg - it may give you the clues about message routing that help you. Good luck - missing messages are not magic, but they can be a pain to track down. Iain.

        1 Reply Last reply
        0
        • M masnu

          I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:

          void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
          {

          // Update menu
          pCmdUI->SetCheck( m_bShowPeakVoltage );

          }

          The menu item does not update, however. I'm I missing something? Thanks.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          For a dialog, you need to handle the undocumented WM_KICKIDLE message to get the command enablers working. See: WM_KICKIDLE for Updating MFC Dialog Controls[^] If you are tracking a popup menu, you may need to set the menu item states before calling TrackPopupMenu(Ex). Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          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