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 » Updating Command-UI without ON_UPDATE_COMMAND_UI macro Collapse All
Subject Author Date
Suhai Gyorgy Nov 2, 2005 - 7:22 AM

Dear Support,


I have to enable/disable some of my commands on Toolbar+MenuBar. But the needed check is a lengthy operation for me so if I use ON_UPDATE_COMMAND_UI macro to update buttons’ states, my application slows down extremely. So I am trying to do the enabling/disabling with CExtToolControlBar::SetButtonStyle only when needed. My code is like this (when disabling):


int iCommandIndex = m_wndToolBar.CommandToIndex(ID_MYCOMMAND);
m_wndToolBar.SetButtonStyle(iCommandIndex, m_wndToolBar.GetButtonStyle(iCommandIndex)|(~TBBS_DISABLED));


The result of this is that the icon disappears from the toolbar. How can I make my button only grayed/dimmed, but still visible?


Thank you: Chris.

Technical Support Nov 4, 2005 - 2:02 AM

The CExtToolControlBar class is based on MFC’s command updating mechanism. It is always used by CExtToolControlBar class in the frame windows or in the CExtResizableDialog windows. But you can create your own toolbar buttons (a CExtBarButton-derived class) with some custom updating behavior. In your class, implement the CExtBarButton::OnUpdateCmdUI() virtual method if you need to use your specific button updating technique in it. This is often used for implementing buttons like a bitmap label in toolbars.

We recommend you use the standard MFC’s command updating. The command updating method should know the last state of the command. If retrieving command state is a lengthy operation, then you can do it periodically by timer and keep the last updating results in the main frame’s properties.