Page 1 of 1

SetWindowState unhides - Bug or Feature?

Posted: Thu May 08, 2008 7:56 am
by dige
I'm not sure. Should it be possible to maximize an hidden window?

I'd like to create a window with lot of gadgets and restore it with
the styles and dimensions from a saved session.
And only wants to show if everything is ready..

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "SetWindowStateBug", #PB_Window_SystemMenu|#PB_Window_Invisible)
MessageRequester( "", "Windows is unvisible", 0 )
; Window should stay unvisible..
SetWindowState( 0, #PB_Window_Maximize )
MessageRequester( "", "Windows is still unvisible??", 0 )
HideWindow(0, #False)
MessageRequester( "", "Windows is now visible", 0 )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Posted: Thu May 08, 2008 9:08 am
by Fangbeast
HideWindow(#Window_Icat, 0) ; Unhide the window now

Didn't unhide it!!

SetWindowState(#Window_Icat, #PB_Window_Normal)

Now it did.

Found this for a couple of pb versions to 4.10. Haven't tried it with 4.2 yet. Even with the maximize flag, same problem.

Posted: Thu May 08, 2008 12:17 pm
by freak
dige:
Its a Windows feature i guess. SetWindowState simply calls ShowWindow(x, SW_MAXIMIZE),
and it seems this cannot be combined with SW_HIDE:

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "SetWindowStateBug", #PB_Window_SystemMenu|#PB_Window_Invisible)
MessageRequester( "", "Windows is unvisible", 0 )
; Window should stay unvisible..
;SetWindowState( 0, #PB_Window_Maximize )
ShowWindow_(WindowID(0), #SW_MAXIMIZE|#SW_HIDE)
MessageRequester( "", "Windows is still unvisible??", 0 )
HideWindow(0, #False)
MessageRequester( "", "Windows is now visible", 0 )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
Fangbeast: show some code please.

Maybe you just have the window in the minimized state and then showing it will of course not make
it appear on screen.

Posted: Thu May 08, 2008 1:03 pm
by tinman
As a solution, it seems to work if you create the window invisible and maximised, so you would have to get the sizes from your session and apply them at the point you create the Window.

Code: Select all

OpenWindow(0, 0, 0, 0, 0, "SetWindowStateBug", #PB_Window_SystemMenu|#PB_Window_Invisible|#PB_Window_Maximize)
MessageRequester( "", "Windows is unvisible", 0 )
; Window should stay unvisible..
;SetWindowState( 0, #PB_Window_Maximize )
;MessageRequester( "", "Windows is still unvisible??", 0 )
HideWindow(0, #False)
MessageRequester( "", "Windows is now visible", 0 )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

Posted: Fri May 09, 2008 8:04 am
by dige
@Tinman: good idea! thanks