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 button with text Collapse All
Subject Author Date
Holger Hellenschmidt Apr 21, 2005 - 9:01 AM

Hi,


I want to show icon with text on some of the toolbar buttons using CExtCmdItem::m_sToolbarText. Everything is working fine, but when I add CExtCustomizeSite::EnableCustomization(), all buttons are shown without text to the right. How can I setup a configuration where text for some buttons is shown?

Technical Support Apr 21, 2005 - 10:28 AM

If your application is customizable (i.e., based on CExtCustomizeSite), any command item in menus/toolbars has two command tree nodes: the initial and the customized. The initial node is used to reset the properties of a command tree node in the customize mode (when the Customize dialog is open and the user can edit/reset any command properties). The command tree nodes are implemented as instances of the CExtCustomizeCmdTreeNode class. You can get both initial and customized command tree nodes for each toolbar button and change the display style of the button to Text and image. In your case, the text in toolbar is not visible because the default display style of all the command tree nodes is not Text and image.

Here is a code snippet that demonstrates how it can be done:

 
void CMainFrame::_SetCmdStateTextAndImage
   ( CExtToolControlBar * pBar, UINT nCmdID )
{
// get the root command tree nodes for toolbar 
// (children nodes of these roots are representing 
// command buttons in toolbar) 
CExtCustomizeCmdTreeNode * pNodeRootInitial = 
      CExtCustomizeSite::GetToolbarCmdNode( 
            pBar, 
            true 
            ); 
ASSERT_VALID( pNodeRootInitial ); 
CExtCustomizeCmdTreeNode * pNodeRootCurrent = 
      CExtCustomizeSite::GetToolbarCmdNode( 
            pBar, 
            false            
            ); 
ASSERT_VALID( pNodeRootCurrent ); 
 
// get the command tree nodes for the 
// toolbar button with command nCmdID 
CExtCustomizeCmdTreeNode * pNodeButtonInitial = 
      pNodeRootInitial->ElementAt(
            pNodeRootInitial->SearchNode( nCmdID )
            );
ASSERT_VALID( pNodeButtonInitial ); 
 
CExtCustomizeCmdTreeNode * pNodeButtonCurrent = 
      pNodeRootCurrent->ElementAt( 
            pNodeRootCurrent->SearchNode( nCmdID )
            ); 
ASSERT_VALID( pNodeButtonCurrent ); 
 
// change display style of button’s nodes 
// (remove display style flags and then assign new) 
pNodeButtonInitial->ModifyFlags( 0, __ECTN_DISPLAY_MASK ); 
pNodeButtonCurrent->ModifyFlags( 0, __ECTN_DISPLAY_MASK ); 
pNodeButtonInitial->ModifyFlags( __ECTN_DISPLAY_TEXT_AND_IMAGE ); 
pNodeButtonCurrent->ModifyFlags( __ECTN_DISPLAY_TEXT_AND_IMAGE ); 
}

Holger Hellenschmidt Apr 21, 2005 - 10:46 AM

Hi,


thanks for the quick response, it works perfect.