ToolBar autosize

Just starting out? Need help? Post your questions and find answers here.
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

ToolBar autosize

Post by RJP Computing »

How do you make the ToolBar resize or autosize. Also is there a way to make it on the right or left or bottom of the window?

Thanks
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

This is one way I know of:

Code: Select all

OpenWindow(0,100,100,10,240,#PB_Window_SystemMenu,"Test")
CreateMenu(0, WindowID(0))
MenuItem(1, "New") 
MenuItem(2, "Open") 
;MenuItem(3, "Save") 

CreateToolBar(1, WindowID(0))
ToolBarStandardButton(1, #PB_ToolBarIcon_New) 
ToolBarStandardButton(2, #PB_ToolBarIcon_Open) 
ToolBarStandardButton(3, #PB_ToolBarIcon_Save) 
SendMessage_(1, #TB_AUTOSIZE, 0, 0)

ResizeWindow(320, 240) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
As you can see the Toolbar has a minimum size, it should be the same as the minimum size of a window in Windows (you can change it somewhere...)

I am to provide the public with beneficial shocks.
Alfred Hitshock
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Just remembered, long time ago I tried to resise a toolbar with other sendmessages, also tried to make a double row toolbar or resize the button size, and it didn't work 100%.
Got the sizes right, but the tooltip was on the wrong spot (locations for a normal sized toolbar)
It was so weird, that I stopped my tests.
As I said it was long time ago (it was with PureBasic 2.6 or so...) and I used the build-in Toolbar and Tooltips

BTW Danilo made once a special toolbar library with some cool stuff.
I think the name was CoolToolbar or similar (I don't use it...)

I am to provide the public with beneficial shocks.
Alfred Hitshock
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

Post by RJP Computing »

fsw wrote:This is one way I know of:

Code: Select all

OpenWindow(0,100,100,10,240,#PB_Window_SystemMenu,"Test")
CreateMenu(0, WindowID(0))
MenuItem(1, "New") 
MenuItem(2, "Open") 
;MenuItem(3, "Save") 

CreateToolBar(1, WindowID(0))
ToolBarStandardButton(1, #PB_ToolBarIcon_New) 
ToolBarStandardButton(2, #PB_ToolBarIcon_Open) 
ToolBarStandardButton(3, #PB_ToolBarIcon_Save) 
SendMessage_(1, #TB_AUTOSIZE, 0, 0)

ResizeWindow(320, 240) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
As you can see the Toolbar has a minimum size, it should be the same as the minimum size of a window in Windows (you can change it somewhere...)
That doesn't seem to work. Could there be another message I need to send when WM_SIZE is sent?

Thanks
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

This is not correct:

Code: Select all

CreateToolBar(1, WindowID(0))
ToolBarStandardButton(1, #PB_ToolBarIcon_New)
ToolBarStandardButton(2, #PB_ToolBarIcon_Open)
ToolBarStandardButton(3, #PB_ToolBarIcon_Save)
SendMessage_(1, #TB_AUTOSIZE, 0, 0) ; <--
This should work:

Code: Select all

hToolbar = CreateToolBar(1, WindowID(0))
ToolBarStandardButton(1, #PB_ToolBarIcon_New)
ToolBarStandardButton(2, #PB_ToolBarIcon_Open)
ToolBarStandardButton(3, #PB_ToolBarIcon_Save)
SendMessage_(hToolbar, #TB_AUTOSIZE, 0, 0)
El_Choni
Post Reply