IsHideWindow
-
- Addict
- Posts: 1520
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
IsHideWindow
I propose to add a function IsHideWindow, that would be similar to WinAPI functions IsWindowVisible.
Now in PB can not be determined visible window.
Now in PB can not be determined visible window.
- BasicallyPure
- Enthusiast
- Posts: 539
- Joined: Thu Mar 24, 2011 12:40 am
- Location: Iowa, USA
Re: IsHideWindow
I would vote for this feature.
+1
+1
Last edited by BasicallyPure on Mon Aug 10, 2015 3:29 am, edited 2 times in total.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Until you know everything you know nothing, all you have is what you believe.
-
- User
- Posts: 43
- Joined: Thu Nov 27, 2014 3:10 pm
- Location: San Juan, Puerto Rico
Re: IsHideWindow
Yes, this would be usefull! Instead of adding another command I suggest to add #PB_Window_Hidden to Set/GetWindowState() and declare HideWindow() deprecated.
Stanley decided to go to the meeting room...
- BasicallyPure
- Enthusiast
- Posts: 539
- Joined: Thu Mar 24, 2011 12:40 am
- Location: Iowa, USA
Re: IsHideWindow
I had this same thought as well but after thinking about it further I decided it would not work.Karellen wrote:Yes, this would be usefull! Instead of adding another command I suggest to add #PB_Window_Hidden to Set/GetWindowState() and declare HideWindow() deprecated.
That is why my post above shows two edits.
Here is why I think it will not work.
GetWindowState() returns a single value.
This is fine as it is now because the window can be in one of three states, normal, maximized, or minimized.
These states are exclusive, the window cannot be in two of these states at one time.
Now if you add "Hidden" to the mix the states are no longer exclusive.
The window can be (normal hidden),( maximized not hidden), (minimized hidden) etc.
The state can no longer be expressed by returning a single value.
It could be made to work if different bits of the return value are used to indicate the states.
You would have to decode the return value using the bitwise and operator '&' with the constant indicating the state of interest.
This would be similar to the way GetGadgetItemState() works.
Last edited by BasicallyPure on Mon Aug 10, 2015 4:49 pm, edited 1 time in total.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Until you know everything you know nothing, all you have is what you believe.
Re: IsHideWindow
This would be nice for crossplatform. I concur. +1
Proud supporter of PB! * Musician * C64/6502 Freak
Re: IsHideWindow
True, you're right! Should think longer before posting a suggestion...BasicallyPure wrote:Karellen wrote:These states are exclusive, the window cannot be in two of these states at one time.

Sounds like that IsWindowHidden() seems to be the way!
+1 anyway
Stanley decided to go to the meeting room...
Re: IsHideWindow
But you hid it, so you know it's hidden. No need to check. Use a variable to keep track of it, if needed.
-
- Addict
- Posts: 1520
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: IsHideWindow
Trond, If we follow your logic, then the PB need to remove function GetWindowState, GetWindowColor, WindowX, WindowY, and many others, because you can use a variable. But will it be convenient?
Re: IsHideWindow
+1
wilbert thank 
Code: Select all
CompilerIf Not Defined(IsHideWindow, #PB_Function)
CompilerIf #PB_Compiler_OS =#PB_OS_Linux And Not Defined(gtk_widget_get_visible, #PB_Procedure)
ImportC ""
gtk_widget_get_visible(*widget.GtkWidget)
EndImport
CompilerEndIf
ProcedureDLL IsHideWindow(Window, State = -1, Flags = 0) ;Returns TRUE is window (from number or handle) hidden
If IsWindow(Window)
If State = -1
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
If Not IsWindowVisible_(WindowID(Window))
ProcedureReturn #True
EndIf
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
If Not gtk_widget_get_visible(WindowID(Window))
ProcedureReturn #True
EndIf
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
If Not CocoaMessage(0, WindowID(Window), "isVisible")
ProcedureReturn #True
EndIf
CompilerEndIf
Else
HideWindow(Window, State, Flags)
EndIf
EndIf
EndProcedure :Macro HideWindow( Window, State = -1, Flags = 0 ) :IsHideWindow( Window, State, Flags ) :EndMacro
CompilerEndIf
CompilerIf #PB_Compiler_IsMainFile
Window = OpenWindow(#PB_Any,0,0,200,40,"Show Window_0",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ShowHide = ButtonGadget(#PB_Any,5,5,190,30,"Hide Window_0?")
Window_0 = OpenWindow(#PB_Any,20,10,250,200,"Show Window_0",#PB_Window_SystemMenu|#PB_Window_NoActivate)
Window_1 = OpenWindow(#PB_Any,320,10,250,200,"Show Window_1",#PB_Window_SystemMenu|#PB_Window_Invisible|#PB_Window_NoActivate)
StickyWindow(Window,#True)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = ShowHide
If HideWindow(Window_1)
HideWindow(Window_1, #False, #PB_Window_NoActivate)
HideWindow(Window_0, #True)
SetGadgetText(ShowHide, "Hide Window_1?")
SetWindowTitle(Window, "Show Window_1")
Else
HideWindow(Window_0, #False, #PB_Window_NoActivate)
HideWindow(Window_1, #True)
SetGadgetText(ShowHide,"Hide Window_0?")
SetWindowTitle(Window,"Show Window_0")
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
CompilerEndIf
; IDE Options = PureBasic 5.24 LTS (Windows - x64)
; CursorPosition = 46
; FirstLine = 17
; Folding = 8-
; EnableUnicode
; EnableXP

Last edited by mestnyi on Fri Nov 13, 2015 2:29 pm, edited 3 times in total.
Re: IsHideWindow
very good mestnyi! very clever!
Thanks for that!

Thanks for that!
If translation=Error: reply="Sorry, Im Spanish": Endif
Re: IsHideWindow
@mestnyi, for OSX you can get the info like this
Code: Select all
If Not CocoaMessage(0, WindowID(Window), "isVisible")
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)