Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Check boxes in Ribbon Bar Samples Collapse All
Subject Author Date
Andrew Banks Jan 3, 2007 - 1:47 PM

When clicked, check mark does not stay on in box.

Sergiy Lavrynenko Jan 4, 2007 - 8:41 AM

Dear Andrew,

The check boxes in your message are toolbar buttons implemented in the CExtBarCheckBoxButton class. All the toolbar buttons are controlled by the MFC’s command updating mechanism either in toolbar, menu bar, panel bar, ribbon page or ribbon bar. So, if the check box button in your ribbon bar uses some ID_MY_CHECK command identifier, then the main frame or dialog window should have the following methods and message map entries for this check box command:

// insert this into the message map of the main frame/dialog window
ON_COMMAND( ID_MY_CHECK, OnMyCheck )
ON_UPDATE_COMMAND_UI( ID_MY_CHECK, OnUdateMyCheck )

// insert this into the class declaration in the .H file
bool m_bMyCheckState; // intialize it in costructor
afx_msg void OnMyCheck();
afx_msg void OnUdateMyCheck( CCmdUI * pCmdUI );

// insert this into the class implementation in the .CPP file
void CMainFrame::OnMyCheck()
{
    m_bMyCheckState = ! m_bMyCheckState;
}

void CMainFrame::OnUdateMyCheck( CCmdUI * pCmdUI )
{
    pCmdUI->Enable();
    pCmdUI->SetCheck( m_bMyCheckState ? 1 :  0 );
}