-
June 30th, 2009, 10:51 AM
#1
Toolbar button sizes
I've created a toolbar that has text to the right of the icon using the TBSTYLE_LIST style and added text to a button using SetButtonText(). Initially, the button size is not changed to reflect the fact that there is now text on the button. Various pages online solve this by using SetSizes on the toolbar to set the button size correctly.
My problem is that this sets all the button sizes to the same width. Only the first two buttons on my toolbar have text, the others I want to only have icons.
Is there a way to set the size (width) for individual buttons on the toolbar?
-
June 30th, 2009, 12:31 PM
#2
Re: Toolbar button sizes
Try CToolBarCtrl::SetButtonInfo
Victor Nijegorodov
-
June 30th, 2009, 12:42 PM
#3
Re: Toolbar button sizes
As far as I'm aware, and according to the msdn docs, SetButtonInfo only sets the width of a separator. For all other types it sets the index of the image to use.
-
June 30th, 2009, 12:48 PM
#4
Re: Toolbar button sizes
Originally Posted by rioch
As far as I'm aware, and according to the msdn docs, SetButtonInfo only sets the width of a separator. For all other types it sets the index of the image to use.
I pointed out that you should try CToolBarCtrl::SetButtonInfo method, not a CToolBar::SetButtonInfo
Victor Nijegorodov
-
June 30th, 2009, 01:18 PM
#5
Re: Toolbar button sizes
My mistake. So to use this I'll have to derive from CToolBar and add some functions to set the button sizes. Is there a good place to do this such that all button size according to text width? Perhaps CToolBar::OnSize?
-
June 30th, 2009, 03:46 PM
#6
Re: Toolbar button sizes
Originally Posted by rioch
My mistake. So to use this I'll have to derive from CToolBar and add some functions to set the button sizes. Is there a good place to do this such that all button size according to text width? Perhaps CToolBar::OnSize?
You don't need to derive.
But if you want to - what is the problem?
Victor Nijegorodov
-
July 1st, 2009, 02:43 AM
#7
Re: Toolbar button sizes
I've created the toolbar using the style TBSTYLE_LIST. I've tried the code below, but neither the text appears nor the button size changes. If I remove the text from the buttonInfo and set it instead with m_wndToolBar1.SetButtonText() the text appears (to the right) but all the buttons take the same width again - in fact, in this case, it chops off the end of the toolbar.
TBBUTTONINFO buttonInfo;
buttonInfo.cbSize = sizeof(buttonInfo);
buttonInfo.dwMask = TBIF_SIZE | TBIF_STYLE;
buttonInfo.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE;
buttonInfo.cx = 150;
buttonInfo.pszText = "Something...";
m_wndToolBar1.GetToolBarCtrl().SetButtonInfo(1, &buttonInfo);
-
July 2nd, 2009, 06:32 AM
#8
Re: Toolbar button sizes
Any help on this? I'm stumped.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|