May 06, 2024, 04:53:48 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


ToolBar problem

Started by LarryMc, May 19, 2010, 11:02:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

I think I'm having one of those problems where I've looked at the code so long I'm not seeing the problem.

After I create my window I add a toolbar and adjust the size of the buttons with this:
IF LOADTOOLBAR(main,"C:\__VD2\Toolbar.bmp",main_tbar1,tbArray, 7,@TBTOOLTIPS|@TBRIGHT|@TBNORESIZE)
ENDIF
CONTROLCMD(main,main_tbar1,@TBSETBITMAPSIZE, 16, 15)
CONTROLCMD(main,main_tbar1,@TBSETBUTTONSIZE, 55, 43)
INT tbleft, tbtop, tbw, tbh, tbbw, tbbh
GETCLIENTSIZE main, tbleft, tbtop, tbw, tbh
tbbw = CONTROLCMD(main,main_tbar1,@TBGETBUTTONWIDTH)
tbbh = CONTROLCMD(main,main_tbar1,@TBGETBUTTONHEIGHT)
SETSIZE main, tbleft+tbw-tbbw-1, tbtop, tbbw+2, tbh,main_tbar1

and in my window handler I have the following code in the @IDSIZE handler:
CONTROLCMD(main,main_tbar1,@TBSETBITMAPSIZE, 16, 15)
CONTROLCMD(main,main_tbar1,@TBSETBUTTONSIZE, 55, 43)
INT tbleft, tbtop, tbw, tbh, tbbw, tbbh
GETCLIENTSIZE main, tbleft, tbtop, tbw, tbh
tbbw = CONTROLCMD(main,main_tbar1,@TBGETBUTTONWIDTH)
tbbh = CONTROLCMD(main,main_tbar1,@TBGETBUTTONHEIGHT)
SETSIZE main, tbleft+tbw-tbbw-1, tbtop, tbbw+2, tbh,main_tbar1

When I run the program the buttons appear in their default size(but the band for the toolbar is in the desired button width,picture#1)
when I resize the buttons change to the desired appearance(picture #2)

If I remove the the setbitmapsiz and setbuttonsize commands from the @IDSIZE handler the button come up like picture #1 but when the window is resized the toolbar appears with the default sizes as in picture #3.

Can anyone see where I messed up?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

Larry, this is from the SDK/MSDN:

TB_SETBUTTONSIZE Message
Sets the size of the buttons to be added to a toolbar.
The size can be set only before adding any buttons to the toolbar.
end quote.

After you call @TBSETBUTTONSIZE for the first time, resize the toolbar using the @TBRESIZE command, it will force the toolbar to apply new sizes for buttons.
Maybe you should call TBSETBUTTONSIZE before LOADTOOLBAR ?

LarryMc

Found it!

Appears to be another one of those 'do it in the right order' things.

I set the size of the buttons and THEN set the content of the labels.

By reversing that order the buttons appeared correctly before and after resizing.
Also, I didn't need to set the sizes again in the @IDSIZE handler either.

Sapero:
QuoteMaybe you should call TBSETBUTTONSIZE before LOADTOOLBAR ?
I hesitate to even respond to this. ;)
I can't really send messages to a control before it is created, can I?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

LOADTOOLBAR
Loads and creates a tool bar control.

Yup! I was sure the toolbar is already created by the CONTROL command. Its my bad day.

LarryMc

Quote from: sapero on May 19, 2010, 12:58:48 PM
LOADTOOLBAR
Loads and creates a tool bar control.
Yup! I was sure the toolbar is already created by the CONTROL command. Its my bad day.
Hey, Sapero, when you get my age you have weeks and months like that. ;D

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library