Page 1 of 1

#PB_Window_Invisible does not remain true

Posted: Thu Aug 02, 2012 4:01 am
by IdeasVacuum
I was hoping that a Window created invisible would stay that way if resized, but it doesn't:

Code: Select all

Structure FFmap
  key.b[256]
EndStructure

Define Keys.FFmap

MessageRequester("Keys","M - Window Maximize" + #CRLF$ + "N - Window Normal" + #CRLF$ + "Esc - End Program")

If OpenWindow(0,0,0,200,200, "You Cannot see me?",#PB_Window_Invisible)

       SetActiveWindow(0)
           ;HideWindow(0,#True)

       Repeat

             iEvent = WaitWindowEvent(1)
                      GetKeyboardState_(@Keys)

             If Keys\key[#VK_M] & %10000000 : SetWindowState(0,#PB_Window_Maximize) : EndIf
             If Keys\key[#VK_N] & %10000000 : SetWindowState(0,#PB_Window_Normal) : EndIf
             If Keys\key[#VK_ESCAPE] & %10000000 : iEvent = #PB_Event_CloseWindow : EndIf

       Until iEvent = #PB_Event_CloseWindow

EndIf

End
I know this is an odd requirement but it was intended as a workaround for this scenario: PC has multiple monitors but each is a different size.
Examine Desktops can be used to confirm there is more than one display, but how do you know which one your app is on? My app needs to know the size of the display it is on, hence the hidden Window - the hidden Window goes wherever the main app Window goes and the idea was to maximize the hidden Window temporarily when the display size is required. Well, I thought it was a good idea...... :? There must be a simpler method anyway?

Re: #PB_Window_Invisible does not remain true

Posted: Thu Aug 02, 2012 4:23 am
by IdeasVacuum
...if I setup the hidden window as a transparent window instead, the above idea does work well - still seems like a naff way to get there though.

Code: Select all

If OpenWindow(00,0,200,200, "Hidden all the time",#PB_Window_BorderLess)
                        SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, #WS_EX_LAYERED)
              SetLayeredWindowAttributes_(WindowID(0),#BLUE,0,#LWA_COLORKEY)
                           SetWindowColor(0,#BLUE)
EndIf

Re: #PB_Window_Invisible does not remain true

Posted: Thu Aug 02, 2012 7:00 am
by Danilo
IdeasVacuum wrote:but how do you know which one your app is on?
The following functions each return the handle of the monitor:

Code: Select all

MonitorFromPoint_()
MonitorFromRect_()
MonitorFromWindow_()
IdeasVacuum wrote:My app needs to know the size of the display it is on
Use GetMonitorInfo_() with the monitor handle to get the display size informations.

Re: #PB_Window_Invisible does not remain true

Posted: Thu Aug 02, 2012 8:05 am
by IdeasVacuum
....thanks Danilo 8)

Re: #PB_Window_Invisible does not remain true

Posted: Fri Aug 03, 2012 2:09 am
by IdeasVacuum
... so, I searched the forum to find out how to use GetMonitorInfo_()
The first post I found about it was written by me! :shock: Clearly, grey hair is bad for you.

blueznl posted some excellent info on detecting Multiple Monitors:
Multiple Monitors