I created the toolbars using Danilo's great TBPro library, and used a combo box to switch between them.
The interesting part was getting a combo box in all the toolbars without having to create/manage more than one combo box.
This example shows a simple way to switch toolbars using a combo box:
Code: Select all
Declare MakeToolBar(TBNumber.l, StartButton.l, WindowHandle.l, IconSize.l, Style.l)
Declare ShowToolBar(ToolBar.l, Show.l)
; create window and gadget list
hWnd.l = OpenWindow(0, 100, 200, 200, 260, #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_Invisible, "ToolBar example")
CreateGadgetList(WindowID())
; make three similar toolbars
Style.l = #TBPro_FLAT|#TBpro_TRANSPARENT|#TBpro_BORDER
MakeToolBar(0, #TBpro_CUT, hWnd, 16, Style)
MakeToolBar(1, #TBpro_DELETE, hWnd, 16, Style)
MakeToolBar(2, #TBpro_FIND, hWnd, 16, Style)
; show first toolbar
ShowToolBar(0, #True)
; show window
HideWindow(0, #False)
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
If EventGadgetID() = 1
; combobox changed - switch toolbars
If EventType() = #PB_EventType_RightClick
; show selected toolbar, hide others
Index.l = GetGadgetState(1)
For TB.l = 0 To 2
If TB = Index
ShowToolBar(TB, #True)
Else
ShowToolBar(TB, #False)
EndIf
Next
EndIf
EndIf
Case #PB_EventMenu
; toolbar button clicked
MessageRequester("Information", "ToolBar " + Str(GetGadgetState(1)) + " Button " + Str(EventMenuID()), 0)
EndSelect
Until EventID = #PB_Event_CloseWindow
;- make toolbar
Procedure MakeToolBar(TBNumber.l, StartButton.l, WindowHandle.l, IconSize.l, Style.l)
; create toolbar
CreateTB(TBNumber, WindowHandle, IconSize, IconSize, Style)
SetTBimage(TBNumber, 0, #TBpro_NORMAL)
SetTBimage(TBNumber, 0, #TBpro_Hot)
SetTBimage(TBNumber, 0, #TBpro_Disabled)
AddTBsysIcons()
; make room for combobox
AddTBseparator(85)
; add buttons
For b.l = 0 To 4
AddTBbutton(b+1, StartButton+b, 0)
Next
; keep toolbar hidden
HideTB(TBNumber, #True)
EndProcedure
;- show/hide specified toolbar
Procedure ShowToolBar(ToolBar.l, Show.l)
If Show
; put combobox in specified toolbar
UseGadgetList(WindowID())
FreeGadget(1)
combo.l = ComboBoxGadget(1, 0, 0, 80, 100)
AddGadgetItem(1, -1, "One")
AddGadgetItem(1, -1, "Two")
AddGadgetItem(1, -1, "Three")
SetGadgetState(1, ToolBar)
UseTB(ToolBar)
AddTBgadget(combo, 2, 2)
; show toolbar
HideTB(ToolBar, #False)
Else
; hide toolbar
HideTB(ToolBar, #True)
EndIf
EndProcedure
Eric