IsHideWindow

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

IsHideWindow

Post by User_Russian »

I propose to add a function IsHideWindow, that would be similar to WinAPI functions IsWindowVisible.
Now in PB can not be determined visible window.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 539
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: IsHideWindow

Post by BasicallyPure »

I would vote for this feature.
+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.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: IsHideWindow

Post by davido »

+1
DE AA EB
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: IsHideWindow

Post by RSBasic »

+1
Image
Image
User avatar
minimy
Enthusiast
Enthusiast
Posts: 563
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: IsHideWindow

Post by minimy »

+1
If translation=Error: reply="Sorry, Im Spanish": Endif
Amilcar Matos
User
User
Posts: 43
Joined: Thu Nov 27, 2014 3:10 pm
Location: San Juan, Puerto Rico

Re: IsHideWindow

Post by Amilcar Matos »

+1
Karellen
User
User
Posts: 83
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: IsHideWindow

Post by Karellen »

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...
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 539
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: IsHideWindow

Post by BasicallyPure »

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.
I had this same thought as well but after thinking about it further I decided it would not work.
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.
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 283
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: IsHideWindow

Post by oreopa »

This would be nice for crossplatform. I concur. +1
Proud supporter of PB! * Musician * C64/6502 Freak
Karellen
User
User
Posts: 83
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: IsHideWindow

Post by Karellen »

BasicallyPure wrote:
Karellen wrote:These states are exclusive, the window cannot be in two of these states at one time.
True, you're right! Should think longer before posting a suggestion... :oops:
Sounds like that IsWindowHidden() seems to be the way!

+1 anyway
Stanley decided to go to the meeting room...
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: IsHideWindow

Post by Trond »

But you hid it, so you know it's hidden. No need to check. Use a variable to keep track of it, if needed.
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: IsHideWindow

Post by User_Russian »

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?
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: IsHideWindow

Post by mestnyi »

+1

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
wilbert thank :)
Last edited by mestnyi on Fri Nov 13, 2015 2:29 pm, edited 3 times in total.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 563
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: IsHideWindow

Post by minimy »

very good mestnyi! very clever! :D
Thanks for that!
If translation=Error: reply="Sorry, Im Spanish": Endif
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: IsHideWindow

Post by wilbert »

@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)
Post Reply