Professional UI Solutions
Site Map   /  Register


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 General Discussion » how to catch modify the state of check box button in the Ribbon bar? Collapse All
Subject Author Date
Mao Feng May 14, 2007 - 11:18 PM

Dear Sir,

In the sample of RibbonBar, I find that the check box in the View page comes back to uncheckd state when the mouse is released. How to pragmatically modify its state after the check box button is clcked?

thx advanced!

Technical Support May 15, 2007 - 8:18 AM

The check boxes in the Ribbon Bar 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

// 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->SetCheck( m_bMyCheckState ? 1 :  0 );

Mao Feng May 15, 2007 - 6:29 PM

Great! So simply to handle it!

Best Regards!