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 » Displaying toolbar button text instead of image? Collapse All
Subject Author Date
Soo Wei Tan Jan 25, 2007 - 11:19 AM

Is there any way of displaying text only for a particular button on a toolbar? I want a particular button to be text-only, while the buttons around it remain as regular toolbar buttons.

On a related note, how do I display both text and image?

Suhai Gyorgy Jan 26, 2007 - 3:08 AM

Whether there is text and/or image displayed in toolbar depends not on the button, but rather on the command identifier that the button represents. To set the different styles, you have to do different things depending on whether you have a customizable application or one without the customization subsystem.

With customization, there is a nice FAQ answering your question:How to display both an icon and text for a toolbar button or a menu item in a customizable application? In the last lines of code in that FAQ there’s a style called __ECTN_DISPLAY_TEXT_AND_IMAGE set. You can change that to __ECTN_DISPLAY_TEXTONLY_ALWAYS or __ECTN_DISPLAY_TEXTONLY_IN_MENU to fit your needs. Check Help file for these styles (under CExtCustomizeCmdTreeNode).

Without customization, you have to change some properties of the CExtCmdItem object representing your command. By default, m_sToolbarText property is set to empty string, meaning no text should be displayed in the toolbar button of the particular command. If you assign any text to this property, it’ll appear in the toolbar. The other property you need is m_nIconIdx. If you set this to -1, no icon will be assigned to the command (neither in toolbar, nor in the menu). You can use the following code to get the CExtCmdItem object of the particular command:

	CExtCmdItem * pCmdItem =
			g_CmdManager->CmdGetPtr(
				g_CmdManager->ProfileNameFromWnd(AfxGetMainWnd()), // in OnCreate, you can use pApp->m_pszProfileName
				nCmdId
				);
	ASSERT (pCmdItem != NULL );
	pCmdItem->m_sToolbarText = _T("Some text"); // to set text appearing in toolbar
	pCmdItem->m_nIconIdx = -1; // to remove icon