Vista: Hide window without animation ?
Vista: Hide window without animation ?
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?
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?
-
UserOfPure
- Enthusiast

- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
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_CloseWindowWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Re: Vista: Hide window without animation ?
...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)
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)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Vista: Hide window without animation ?
Yes, and yes. Just use a LARGE negative number though, like -999999, because no monitor will have a desktop size of 999999 pixels wide.c4s wrote:Is it save to assume that negative positions are not on the screen? What about multiple monitors/desktops? (can't test it)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Vista: Hide window without animation ?
@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
Good luck mate
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
Egypt my love
Re: Vista: Hide window without animation ?
@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...
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...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Vista: Hide window without animation ?
@c4s
If it works with Vista and the timing is fine with you
So no problem with the user settings
See next
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
Egypt my love
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Vista: Hide window without animation ?
A negative number isn't going to hide the window unless it's a large negative number. Look: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?!
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
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.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Vista: Hide window without animation ?
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...
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...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Vista: Hide window without animation ?
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:
but there is nothing wrong with -99999 though.
c ya,
nco2k
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
EndProcedurec ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Re: Vista: Hide window without animation ?
Clean solution:
Works fine on Windows 7
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_CloseWindowWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Vista: Hide window without animation ?
If you ran my example, you'd have your answer. That's why I posted it.c4s wrote:I just wanted to know if negative values can be visible in general
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).c4s wrote:I don't feel good about using something like -999999
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
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
