Discussion:
Can't autosize toolbars using TB_AUTOSIZE or any other way
(too old to reply)
Simon
2008-10-07 11:48:45 UTC
Permalink
I want to have a flat toolbar with text showing to the right of some
buttons, but not all. I can achieve this with CToolbar by creating it with
CreateEx with the style TB_STYLE_FLAT and TBSTYLE_EX_MIXEDBUTTONS which
allows me to set button text to the right of some buttons (not all). I then
load the toolbar bitmap by calling LoadToolbar and finally I call
TBSTYLE_AUTOSIZE on each button (otherwise they all have the same size) and
SetButtonText to set the text for those buttons that I want to have text
showing.

This sort of works. Some buttons seem a little off-centre (even without
text) which I don't understand and a separator gets a gap after it that is
much too big - again, I've no idea why. But much more seriously, the overall
toolbar retains the size it would have had if I hadn't added the text to
some buttons. I have tried using SendMessage to send the TB_AUTOSIZE
message to the toolbar (and/or its ctrl) or calling the AutoSize function on
CToolBarCtrl(), but they have no effect at all.

I can't work out what I need to do. I have tried experimenting with flags,
every way I can think. Nothing works. Calling CMainFrame::RecalcLayout(),
resizing the main frame, etc - none of these things make any difference.
I've tried everything I can think of.

Any help with this would be very much appreciated.

Simon
Simon
2008-10-07 13:37:07 UTC
Permalink
Sorry this was accidentally posted to the wrong newsgroup

Loading...