ToolBar hide & show
Posted: Tue Jun 24, 2003 1:51 pm
friends, how can I hide and show a toolbar in a window ?. I need add this feature to gain client size space when the user need it by checking a menu option... :roll:
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
*YourToolBar = CreateToolbar(....)
ShowWindow_(*YourToolBar, #SW_HIDE) ; will hide it
ShowWindow_(*YourToolBar, #SW_SHOWNORMAL) ; will show it
Is the * really necessary?Fred wrote:Code: Select all
*YourToolBar = CreateToolbar(....) ShowWindow_(*YourToolBar, #SW_HIDE) ; will hide it ShowWindow_(*YourToolBar, #SW_SHOWNORMAL) ; will show it
Code: Select all
YourToolBar = CreateToolbar(....)
ShowWindow_(YourToolBar, #SW_HIDE)
ShowWindow_(YourToolBar, #SW_SHOWNORMAL)
Code: Select all
Global TBHandle.l, Quit.l
.....
Quit = 0
.....
Declare VisiTB()
.....
If OpenWindow(0, 50, 50, 150, 100, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "ToolBar test")
If CreateMenu(0, WindowID())
MenuTitle("Test")
MenuItem(0, "Toggle")
SetMenuItemState(0, 0, 1)
EndIf
*TBHandle = CreateToolBar(10, WindowID())
CatchImage(0,?Btn0)
CatchImage(1,?Btn1)
CatchImage(2,?Btn2)
ToolBarImageButton(0,UseImage(0))
ToolBarImageButton(1,UseImage(1))
ToolBarSeparator()
ToolBarImageButton(3,UseImage(2))
For n = 0 To 3
FreeImage(n)
Next
Goto LoopEvents:
EndIf
....
LoopEvents:
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case 0
VisiTB()
EndSelect
Case #WM_CLOSE
Quit = 1
EndSelect
Until Quit = 1
......
End
......
Procedure VisiTB()
If GetMenuItemState(0, 0) = 0
SetMenuItemState(0, 0, 1)
ShowWindow_(*TBHandle, #SW_SHOWNORMAL)
Else
SetMenuItemState(0, 0, 0)
ShowWindow_(*TBHandle, #SW_HIDE)
EndIf
EndProcedure
......Code: Select all
OpenWindow(0,100,150,300,120,#PB_Window_SystemMenu,"ToolBar - Show and Hide")
hToolbar = CreateToolBar(1, WindowID(0))
ToolBarStandardButton(1, #PB_ToolBarIcon_New)
ToolBarStandardButton(2, #PB_ToolBarIcon_Open)
ToolBarStandardButton(3, #PB_ToolBarIcon_Save)
If CreateGadgetList(WindowID())
ButtonGadget(0,50,50,200,20,"Hide ToolBar") : Shown = 1
EndIf
Repeat
ev.l = WaitWindowEvent()
gad.l = EventGadgetID()
If ev = #PB_EventGadget
If gad = 0
If Shown = 1
ShowWindow_(hToolbar, #SW_HIDE) ; now hide toolbar
SetGadgetText(0,"Show ToolBar")
Shown = 0
Else
ShowWindow_(hToolbar, #SW_SHOWNORMAL) ; now shot toolbar
SetGadgetText(0,"Hide ToolBar")
Shown = 1
EndIf
EndIf
EndIf
Until ev.l = #PB_Event_CloseWindow