ToolBar hide & show
ToolBar hide & show
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:
with love from Uruguay
Try:
Code: Select all
*YourToolBar = CreateToolbar(....)
ShowWindow_(*YourToolBar, #SW_HIDE) ; will hide it
ShowWindow_(*YourToolBar, #SW_SHOWNORMAL) ; will show it
-
freedimension
- Enthusiast

- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
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)
PB, here is the code...
Of course this is part of the real program, but I extract the relevants parts...
Please help me.
P.D. I´m programming in a ThinkPad Celeron notebook with 128 Mb of RAM
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
......Please help me.
P.D. I´m programming in a ThinkPad Celeron notebook with 128 Mb of RAM
with love from Uruguay
- Andre
- PureBasic Team

- Posts: 2148
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Here is a small code I put together yesterday from the given hints....
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

