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 » How to disable a CExtBarButton? Collapse All
Subject Author Date
Krustys Donuts Mar 28, 2006 - 5:28 PM

Can you please explain to me why the following code doesn’t work?

int buttonIndex = m_wndMainToolBar.CommandToIndex( ID_DONUTS);
CExtBarButton* pButton = m_wndMainToolBar.GetButton( buttonIndex);
if( static_cast<int>(wParam))
	pButton->ModifyStyle( 0, TBBS_DISABLED);
else
	pButton->ModifyStyle( TBBS_DISABLED, 0);
m_wndMainToolBar.Invalidate();

Technical Support Mar 29, 2006 - 6:56 AM

This code does not work because the toolbar is fully controlled by MFC’s command updating mechanism. The TBBS_DISABLED style of the toolbar button is used internally to remember the last command updating result. Please add command updating handler methods for the toolbar buttons which you need to disable/enable optionally.

Krustys Donuts Mar 28, 2006 - 5:34 PM

oops... sorry, I think it does work. I just noticed that the button flickers, as if it’s being disabled and then reenabled. I’ll dig some more and will post up if I do find a problem.

Technical Support Mar 29, 2006 - 6:57 AM

As we mentioned in the previous answer, the TBBS_DISABLED button style is used just for keeping the last command updating result. Please do not change this flag explicitly and use command updating methods instead.