Please extend GetWindowState()
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Please extend GetWindowState()
PurBasic has the command HideWindow(), but currently there is no corresponding native function that can determine whether or not a given window is hidden. So GetWindowState() should additionally have a possible return value such As #PB_Window_Hidden.
Re: Please extend GetWindowState()
+1
I do this in my app by holding an extra byte in my configuration structure that is #True if the window is shown, #false if it's hidden and I just set it manually, but being able to avoid this painful manual work with a native command would be much appreciated.
I do this in my app by holding an extra byte in my configuration structure that is #True if the window is shown, #false if it's hidden and I just set it manually, but being able to avoid this painful manual work with a native command would be much appreciated.
Re: Please extend GetWindowState()
Retrieves visibility state of window.
Code: Select all
Procedure.b IsHideWindow(WindowNum.q)
If IsWindowVisible_(WindowID(WindowNum))
ProcedureReturn #False ; 0 = Window is visible
Else
ProcedureReturn #True ; 1 = Window is hidden
EndIf
EndProcedure
If OpenWindow(0, 200, 200, 220, 100, "HideWindow()", #PB_Window_SystemMenu)
ButtonGadget (1, 10, 60, 200, 30, "Hide the window")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
HideWindow(0, #True)
Debug "Window hidden."
Debug IsHideWindow(0)
MessageRequester("Info", "Press OK to show the window")
HideWindow(0, #False)
Debug "Window is visible."
Debug IsHideWindow(0)
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Re: Please extend GetWindowState()
Very nice, thanks! Would still love to see a native command, but I dropped this into my project and started using it, and it works flawlessly!
Ventural wrote: Mon Mar 10, 2025 5:34 am Retrieves visibility state of window.Code: Select all
Procedure.b IsHideWindow(WindowNum.q) If IsWindowVisible_(WindowID(WindowNum)) ProcedureReturn #False ; 0 = Window is visible Else ProcedureReturn #True ; 1 = Window is hidden EndIf EndProcedure If OpenWindow(0, 200, 200, 220, 100, "HideWindow()", #PB_Window_SystemMenu) ButtonGadget (1, 10, 60, 200, 30, "Hide the window") Repeat Event = WaitWindowEvent() Select Event Case #PB_Event_Gadget Select EventGadget() Case 1 HideWindow(0, #True) Debug "Window hidden." Debug IsHideWindow(0) MessageRequester("Info", "Press OK to show the window") HideWindow(0, #False) Debug "Window is visible." Debug IsHideWindow(0) EndSelect EndSelect Until Event = #PB_Event_CloseWindow EndIf
Re: Please extend GetWindowState()
Yes.Would still love to see a native command
In the meantime, to keep things simple, just one line is enough:
Code: Select all
IsWindowVisible_( WindowID( 0 ) )
0 = hidden
1 = Visible
Re: Please extend GetWindowState()
How's this one?Marc56us wrote: Mon Mar 10, 2025 3:51 pmYes.Would still love to see a native command
In the meantime, to keep things simple, just one line is enough:ReturnCode: Select all
IsWindowVisible_( WindowID( 0 ) )
0 = hidden
1 = Visible
Code: Select all
Macro IsWindowHidden(_Window) : Not IsWindowVisible_(WindowID(_Window)) : EndMacro

Only sad thing is it's windows only.
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Please extend GetWindowState()
I know the Windows API function IsWindowVisible_().
However, having a cross-platform native PureBasic function for this would make sense IMHO.