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 General Discussion » Setting text on CExtToolControlBar buttons. Collapse All
Subject Author Date
Marat Garafutdinov Sep 4, 2003 - 2:25 PM

How can I set text on the toolbar buttons (bitmaps) ?
In MFC CToolBar class there is a SetButtonText() function, but CExtToolControlBar is derived from CControlBar.

Bui Tan Duoc Feb 1, 2007 - 2:08 AM

How to set position of the text (below button image,...)

Sergiy Lavrynenko Sep 5, 2003 - 1:13 AM

Dear Marat,

The CExtToolControlBar window holds only list of the command identifiers of its buttons. Each button is controlled by the CExtBarButton object which stores one command identifier and button’s RECT. Toolbar does not hold icons and text strings. It uses command manager which knows all about commands. Command magager is implemented in the g_CmdManager global variable which is smart pointer. It stores named collection of CExtCmdProfile objects (or command profiles). Each command profile has a name and list of registered commands. Each command is described by CExtCmdItem object which holds command’s text in menu, toolbar, tooltip and status-bar texts. Most of the Prof-UIS samples have a toolbar with buttons for switching UI style. These buttons have icons and text. To assign text to the command in toolbar you should change its CExtCmdItem::m_sToolbarText property. Here is the typical initialization sequence of CMainFrame::OnCreate():

  • call parent’s frame OnCreate()

  • initialize main view of SDI application

  • change icon of CMainFrame’s caption if needed

  • initialize new command profile in the command manager by invoking g_CmdManager->ProfileSetup(...)

  • update command descriptions in the command manager by invoking g_CmdManager->UpdateFromMenu(...) and g_CmdManager->UpdateFromToolBar(...)

  • create menubar, toolbars, resizable bars, child windows of resizable bars and status bar

  • Enable docking features for all the bars and frame window, load bar’s state and/or initialize their positions

When the command profile’s initialization complete, i.e. you have called g_CmdManager->ProfileSetup(...) and updated command properties with g_CmdManager->UpdateFrom...(...), you can get pointer to CExtCmdItem object of any registered command and assign its "text in toolbar" property:

CExtCmdItem * pCmdItem = g_CmdManager -> CmdGetPtr( profile-name, command-identifier );
ASSERT( pCmdItem != NULL );
pCmdItem -> m_sToolbarText = _T("Show me 2000");
Please take a look at the SDI or MDI sample to see full source code for this post.

Best regards,
Sergiy.