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 » Toolbar Collapse All
Subject Author Date
Sergio Buonanno Mar 15, 2006 - 10:54 AM

Is there a way to get the image ID of a toolbar button ? I mean, as it happens with a standard MFC CToolbarCtrl control, I would like to change image of a CExtToolControlBar button by changing the ID of the button’s image. Is it possibile ?
Thanks

Technical Support Mar 15, 2006 - 12:27 PM

The CExtToolControlBar class implements a toolbar window which is written from scratch and not based on any standard toolbar common control like MFC’s toolbar. The Prof-UIS toolbar class contains an array of CExtBarButton objects which implement toolbar buttons. You can use the CExtToolControlBar::GetButtonsCount(), CExtToolControlBar::GetButton() and CExtToolControlBar::CommandToIndex() methods to access toolbar’s button objects.

Each button object typically has only two command identifiers and nothing else. The basic command identifier is a generic identifier of the toolbar button. The effective command identifier is used as an identifier of the command which the toolbar sends to the command target window. It is also used for searching for toolbar’s icon in the command manager. You can get a toolbar button’s identifier using the CExtToolControlBar::GetCmdID() method.

The effective command identifier can be used to access the command manager to get a pointer to the CExtCmdIcon object which implements the command icon both for toolbar buttons and menu items. The CExtCmdManager::CmdGetIcon() method returns the currently assigned command’s icon. The CExtCmdManager::CmdSetIcon() method assigns a new icon. So, you simply need to assign a new icon with the g_CmdManager->CmdSetIcon(...) code (use the preliminary known effective identifier of the toolbar button in this method). You can simply invalidate the visible toolbar window if the newly assigned icon has the same size as the old icon. You need to recompute the layout of toolbar’s parent window if the icon size is changed (simply invoke pToolBar->GetParentFrame()->RecalcLayout()).