Add any gadget to toolbar (using a container)
Posted: Sat Jun 09, 2007 8:33 pm
Based on the code from eddy, this code allows you to add any kind of gadgets to a toolbar easily.
Code: Select all
Procedure ToolbarContainer(Width, Height, ToolbarID)
Protected Pos.l
Protected Sep.TBBUTTON
Protected Rect.RECT
Pos = SendMessage_(ToolbarID, #TB_BUTTONCOUNT, 0, 0)
ToolBarSeparator()
SendMessage_(ToolbarID, #TB_GETBUTTON, Pos, @Sep)
Sep\iBitmap = Width
SendMessage_(ToolbarID, #TB_DELETEBUTTON, Pos, 0)
SendMessage_(ToolbarID, #TB_INSERTBUTTON, Pos, @Sep)
SendMessage_(ToolbarID, #TB_GETITEMRECT, Pos, @Rect)
UseGadgetList(ToolbarID)
ProcedureReturn ContainerGadget(#PB_Any, Rect\left, 0, Width, Height)
EndProcedure
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
CreateToolBar(0, WindowID(0))
ToolBarStandardButton(0, 0)
ToolBarStandardButton(1, 1)
ToolBarStandardButton(2, 3)
ToolbarContainer(200, ToolBarHeight(0), ToolBarID(0))
StringGadget(0, 0, 1, 150, 20, "Testing")
ButtonGadget(1, 150, 1, 50, 20, "Go!")
ToolBarStandardButton(3, 2)
UseGadgetList(WindowID(0))
StringGadget(2, 50, 50, 123, 20, "asdf")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver