How to display an icon and text for a toolbar button or a menu item in a customizable application?

Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

If your application is customizable (i.e., it is based on CExtCustomizeSite), any command item in a menus or a toolbar has two command tree nodes: the initial and the customized. The initial node is used for resetting 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 nodes for each toolbar button and change its display style to Text and Image.

Here is the example code:

void CMainFrame::_SetCmdStateTextAndImage
   ( CExtToolControlBar * pBar, UINT nCmdID )
// get the root command tree nodes for toolbar 
// (child nodes of these roots represent 
// command buttons in toolbar) 
CExtCustomizeCmdTreeNode * pNodeRootInitial = 
ASSERT_VALID( pNodeRootInitial ); 
CExtCustomizeCmdTreeNode * pNodeRootCurrent = 
ASSERT_VALID( pNodeRootCurrent ); 
// get the command tree nodes for the 
// toolbar button with command nCmdID 
CExtCustomizeCmdTreeNode * pNodeButtonInitial = 
        pNodeRootInitial->SearchNode( nCmdID )
ASSERT_VALID( pNodeButtonInitial ); 
CExtCustomizeCmdTreeNode * pNodeButtonCurrent = 
        pNodeRootCurrent->SearchNode( nCmdID )
ASSERT_VALID( pNodeButtonCurrent ); 
// change display style of button's nodes 
// (remove display style flags and then assign new ones) 
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 );