Page 1 of 2
Vista: Hide window without animation ?
Posted: Mon Aug 24, 2009 1:09 pm
by c4s
When I use HideWindow() it takes a while until the window is invisible
because Windows Vista (and 7 too?) makes a transparency fade etc by
default.
I need it to be hidden immediately without any animations.
Is there a way I can temporarily disable this?
Posted: Mon Aug 24, 2009 1:12 pm
by srod
Try moving the window off-screen before hiding it.
Posted: Mon Aug 24, 2009 6:22 pm
by c4s
This looks like a good idea - I don't even have to hide it.
Thanks.
Posted: Mon Aug 24, 2009 9:21 pm
by UserOfPure
If you don't hide it, it will still have a button on the Taskbar.
Posted: Mon Aug 24, 2009 9:57 pm
by Fluid Byte
First move it then hide it:
Code: Select all
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0,5,5,120,25,"untitled")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
ResizeWindow(0,5000,#PB_Ignore,#PB_Ignore,#PB_Ignore)
HideWindow(0,1)
EndIf
Until EventID = #PB_Event_CloseWindow
Re: Vista: Hide window without animation ?
Posted: Fri Mar 04, 2011 2:15 pm
by c4s
...I don't like that I always find my own posts here when I'm try to find something in the www.
Anyway, I didn't find an answer for this: Is it save to assume that negative positions are not on the screen? What about multiple monitors/desktops? (can't test it)
Re: Vista: Hide window without animation ?
Posted: Fri Mar 04, 2011 2:19 pm
by MachineCode
c4s wrote:Is it save to assume that negative positions are not on the screen? What about multiple monitors/desktops? (can't test it)
Yes, and yes. Just use a LARGE negative number though, like -999999, because no monitor will have a desktop size of 999999 pixels wide.
Re: Vista: Hide window without animation ?
Posted: Fri Mar 04, 2011 3:37 pm
by RASHAD
@c4s Hi
You can disable the animation flag before hiding window
It works fine with win 7 and I guess it will be OK too with vista
Code: Select all
OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ButtonGadget(1,10,10,80,25,"Test",#PB_Button_Toggle)
anm.ANIMATIONINFO\cbSize = SizeOf(ANIMATIONINFO)
anm.ANIMATIONINFO\iMinAnimate = 0 ;1 to enable
SystemParametersInfo_($0049, SizeOf(ANIMATIONINFO), @anm, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Q = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
HideWindow(0,1)
Delay(2000)
HideWindow(0,0)
EndSelect
EndSelect
Until Q = 1
Good luck mate
Re: Vista: Hide window without animation ?
Posted: Fri Mar 04, 2011 5:26 pm
by c4s
@MachineCode
What do you mean by large negative number? I mean the window width plus some pixels for shadows etc. should be enough if a negative is always invisible?!
@Rashad
Thanks for your help. But I don't want to mess with the users system settings, so I rather stick with moving the window to a negative value and then hiding it.
Too bad that there doesn't seem to be a flag that allows to dynamically set the animation state just for the current window...
Re: Vista: Hide window without animation ?
Posted: Fri Mar 04, 2011 5:45 pm
by RASHAD
@c4s
If it works with Vista and the timing is fine with you
So no problem with the user settings
See next
Code: Select all
Global Animflag
;Get minanimation flag
anm.ANIMATIONINFO\cbSize = SizeOf(ANIMATIONINFO)
SystemParametersInfo_($0048, SizeOf(ANIMATIONINFO), @anm, 0)
Animflag = anm.ANIMATIONINFO\iMinAnimate
OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ButtonGadget(1,10,10,80,25,"Test",#PB_Button_Toggle)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Q = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
anm.ANIMATIONINFO\iMinAnimate = 0
SystemParametersInfo_($0049, SizeOf(ANIMATIONINFO), @anm, 0)
HideWindow(0,1)
If Animflag = 1
anm.ANIMATIONINFO\iMinAnimate = 1
SystemParametersInfo_($0049, SizeOf(ANIMATIONINFO), @anm, 0)
EndIf
EndSelect
EndSelect
Until Q = 1
Re: Vista: Hide window without animation ?
Posted: Sat Mar 05, 2011 1:45 am
by MachineCode
c4s wrote:What do you mean by large negative number? I mean the window width plus some pixels for shadows etc. should be enough if a negative is always invisible?!
A negative number isn't going to hide the window unless it's a large negative number. Look:
Code: Select all
OpenWindow(0,0,0,150,50,"Test",#PB_Window_SystemMenu)
ButtonGadget(1,10,10,120,20,"Click to move to -50")
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
ResizeWindow(0,-50,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndIf
Until Event=#PB_Event_CloseWindow
When you click the button, the window moves 50 pixels to the left, but it's still visible. But surely you knew that?
So what you do is use a LARGE negative number, like -999999, to ensure that no monitors (or dual monitors!) will show the window. Because if you have dual monitors and both are 2048 pixels wide, and the window opens on the right-hand one and moves -1000 pixels to the left, then it will be shown on the left-hand one (that is, still visible). So using something insanely large like -999999 gets rid of that possibility, because it's unlikely that the user will be using a monitor that is 999999 pixels wide.

Re: Vista: Hide window without animation ?
Posted: Sat Mar 05, 2011 11:02 am
by c4s
I just wanted to know if negative values can be visible in general.
I think I'm going to use ResizeWindow(0, -WindowWidth(0) - 50, WindowHeight(0) - 50, #PB_Ignore, #PB_Ignore) because I don't feel good about using something like -999999...
Re: Vista: Hide window without animation ?
Posted: Sat Mar 05, 2011 11:43 am
by nco2k
if the user has a second monitor attached left from his primary monitor, he might see your window. yes, desktop values can be negative.
WindowWidth/Height() return the size of the window client area, so WindowHeight(0) - 50 might not be enough, since you dont know how large the titlebar+borders of the user is. yes, the size of the titlebar can be changed.
if you need the real width/height of a window, use something like this:
Code: Select all
Procedure WindowRealWidth(WindowID)
Protected Result, WinRect.RECT
If GetWindowRect_(WindowID, @WinRect)
Result = WinRect\right - WinRect\left
EndIf
ProcedureReturn Result
EndProcedure
Procedure WindowRealHeight(WindowID)
Protected Result, WinRect.RECT
If GetWindowRect_(WindowID, @WinRect)
Result = WinRect\bottom - WinRect\top
EndIf
ProcedureReturn Result
EndProcedure
but there is nothing wrong with -99999 though.
c ya,
nco2k
Re: Vista: Hide window without animation ?
Posted: Sat Mar 05, 2011 7:08 pm
by Fluid Byte
Clean solution:
Code: Select all
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0,5,5,120,25,"Test")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
HideWindow(0,1)
SendMessage_(WindowID(0),#WM_SETREDRAW,1,0)
EndIf
Until EventID = #PB_Event_CloseWindow
Works fine on Windows 7
Re: Vista: Hide window without animation ?
Posted: Sun Mar 06, 2011 12:58 am
by MachineCode
c4s wrote:I just wanted to know if negative values can be visible in general
If you ran my example, you'd have your answer. That's why I posted it.
c4s wrote:I don't feel good about using something like -999999
Why not? X and Y values for window positions, and gadgets, can be anything. It won't crash. When you think about, the desktop area that you see is just a small part of an insanely huge "virtual" desktop, with the top-left of your desktop being co-ordinates 0,0. You can position a window anywhere on the visible desktop, or anywhere outside it in the "virtual" unseen area around it (above, below, left or right).
Here's a visual example which assumes your Windows desktop is 1024x768 pixels:
Code: Select all
-999999,-999999
+----------------------------------+
| |
| |
| |
| 0,0 |
| +---------+ |
| | Desktop | |
| | display | |
| +---------+ |
| 1024,768 |
| |
| |
| |
+----------------------------------+
999999,999999