1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use a Checkbox in a ribbon?

Discussion in 'MFC' started by EGD Eric, Jun 9, 2011.

  1. EGD Eric

    EGD Eric New Member

    Joined:
    Jun 9, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I'm trying to figure out how to use a checkbox inside of a ribbon. The checkboxes I added to my ribbon in the editor get unchecked as soon as I check them, so I tried to create an event handler for my checkbox:
    Code:
    ON_COMMAND(IDC_VIDEO_RECORDING, &CMainFrame::OnVideoRecording)
    
    ....
    
    void CMainFrame::OnVideoRecording()
    {
    	// TODO: Add your command handler code here
    	m_bEnableVideo = !m_bEnableVideo;
    }
    
    Then I figure I can have a ON_UPDATE_COMMAND_UI event created for the checkbox, which would set the checkbox to m_bEnableVideo. Unfortunately, I set a breakpoint and OnVideoRecording never gets entered.

    Maybe I'm on the wrong track? Maybe there's an easier way of doing checkboxes in ribbons in MFC? Any help would be appreciated, thanks, I've been having trouble finding good documentation on this subject. It seems like MFC has changed since I last used it, or maybe its just ribbons that are different, I dunno.

    I set up the project with "MFC standard" for application type, and specified it to "use a ribbon", and I'm not using doc/view architecture.
     
  2. EGD Eric

    EGD Eric New Member

    Joined:
    Jun 9, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Ah, I see the problem now. I had some leftover handler declared in my CChildView class that was grabbing it.
     
  3. EGD Eric

    EGD Eric New Member

    Joined:
    Jun 9, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    BTW, does anyone know a better way of doing it than I'm using?
     

Share This Page