Syntax
Success = WindowShow(Window, isVisible=#True, Flags=0)
Description
Shows or hides the specified ProGUI window. Windows are created initially hidden and must be shown using this command to become visible to the user.
Parameters
Window
The handle of the ProGUI window to show or hide.
isVisible (optional)
Set to #True to show the window or #False to hide it. Default is #True.
Flags (optional)
Additional flags that modify how the window is shown (only applicable when isVisible is #True). Default is 0.
#PG_Window_NoActivate : Shows the window without activating it or giving it input focus.
#PG_Window_ScreenCentered : Centers the window on the screen when shown.
#PG_Window_WindowCentered : Centers the window relative to its parent window (if it has one) when shown.
#PG_Window_NoUpdate : (Internal usage likely) Shows the window immediately using OS functions rather than queuing through the ProGUI update cycle. This might bypass certain ProGUI state initializations if used directly.
Return Value
Returns #True if the operation was successful, or #False if the window handle was invalid.
Remarks
When showing a window, it's common to use flags like #PG_Window_ScreenCentered or #PG_Window_WindowCentered for initial placement. The standard way to show a window involves ProGUI's update cycle (by default or by omitting #PG_Window_NoUpdate), which ensures proper state management. Hiding a window simply makes it invisible; its state and contents are preserved.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Animation IDs
#ANIM_ID_HIDE = 1
#ANIM_ID_SHOW_AGAIN = 2
; Event handler to manage showing/hiding
Procedure DelayedShowHideHandler(Window, EventType, *EventData.PG_EventAnimate, *UserData)
If EventType = #PG_Event_Animate And *EventData\state = #PG_Event_Animate_End
Select *EventData\id
Case #ANIM_ID_HIDE
Debug "Animation 1 finished, hiding window..."
WindowShow(Window, #False)
Debug "Window Hidden"
; Start the next animation to show it again after 2 seconds
StartAnimation(Window, #ANIM_ID_SHOW_AGAIN, 2000)
Debug "Waiting 2 seconds via animation before showing again..."
Case #ANIM_ID_SHOW_AGAIN
Debug "Animation 2 finished, showing window (no activate)..."
WindowShow(Window, #True, #PG_Window_NoActivate)
Debug "Window Shown (No Activate)"
EndSelect
EndIf
EndProcedure
MyWindow = CreateWindow(0, 0, 400, 300, "Show/Hide Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Animate, @DelayedShowHideHandler())
; Show the window centered initially
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Debug "Window Shown"
; Start the first animation timer (2 seconds) to hide the window
StartAnimation(MyWindow, #ANIM_ID_HIDE, 2000)
Debug "Waiting 2 seconds via animation before hiding..."
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
CreateWindow, StartAnimation, AddEventHandler
Supported OS
Windows, Linux