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 » CExtToolControlBar Enable/Disable button Collapse All
Subject Author Date
Yaroslav Nedash Jul 27, 2007 - 4:20 PM

I programmatically add button to CExtToolControlBar. How to enable or disable this button?

Suhai Gyorgy Jul 28, 2007 - 7:32 AM

You should go for the MFC command updating mechanism. This will disable not only the toolbar button, but also any other way the user could invoke the command with this command identifier (e.g. menu entries and accelerator).

1. insert a line in your class’ message map (this class is the one that would handle the command, usually CMainFrame):
2. add the following method for your class:
2.a) in .h:
afx_msg void OnUpdateYourCommand(CCmdUI* pCmdUI);
2.b) in .cpp:
void CYourClass::OnUpdateYourCommand(CCmdUI* pCmdUI)
    pCmdUI->Enable(FALSE); // this disables the command; if you don’t call this line, command will be enabled