Page 1 of 1

Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 12:13 am
by c4s
When I hide a window it take some time for it to be hidden completely (from the taskbar) because of the default hiding animation. By try and error I found out that takes about 250-260ms (on Windows 8.1).

For my application I have to know the exact time it takes because it's probably different on each Windows version and I guess the user can disable it too. Do you know a way to find out if the window animations are enabled and if so how long they take?

It would be even better if I would be able to hide my window immediately, no matter if the user has the animation enabled or not. A trick I'm currently using is to move the window off the screen. That's working fine for the window itself, however the window's tab on the taskbar still animates. Unfortunately even ITaskBarList\DeleteTab() makes no difference. Any suggestions?

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 6:27 am
by RASHAD
Hi
I did that long time back
See if it is of any help

Code: Select all

;#SPI_GETANIMATION = $48
;#SPI_SETANIMATION = $49

Global Animflag

OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
anm.ANIMATIONINFO
anm\cbSize = SizeOf(anm)
SystemParametersInfo_(#SPI_GETANIMATION, SizeOf(anm), @anm, 0)
Animflag = anm\iMinAnimate
ButtonGadget(1,10,10,80,25,"Test")

Repeat
  Select WaitWindowEvent()
     
    Case #PB_Event_CloseWindow
      Q = 1   
       
    Case #PB_Event_Gadget
        Select EventGadget()
          Case 1           
              anm\iMinAnimate = 0
              SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
              ShowWindow_(WindowID(0),#SW_HIDE)
              Delay(2000)
              If Animflag = 1
                anm\iMinAnimate = 1
                SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
                ShowWindow_(WindowID(0),#SW_SHOW)
              EndIf
               
        EndSelect
             
  EndSelect
Until Q = 1

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 12:22 pm
by c4s
Thanks Rashad, this allows me to find out if the animation is enabled. Strange though that ANIMATIONINFO doesn't say how long it takes. Any ideas for that?

By the way, your code disabled the window animation. I also found the following solution:

Code: Select all

HRESULT DisableDwmAnimations(HWND hwnd)
{
    BOOL fDisable = TRUE;
    return DwmSetWindowAttribute(hwnd,
                DWMWA_TRANSITIONS_FORCEDISABLED,
                &fDisable,
                sizeof(fDisable));
}
Unfortunately your code and that one above didn't affect the animation on the taskbar... :(

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 2:37 pm
by RASHAD
Hi c4s
It seems that the next tech. will do your request
Hope that :)

Code: Select all

Global anim,Animflag

OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
anm.ANIMATIONINFO
anm\cbSize = SizeOf(anm)
SystemParametersInfo_(#SPI_GETANIMATION, SizeOf(anm), @anm, 0)
Animflag = anm\iMinAnimate

wp.WINDOWPLACEMENT
wp\Length = SizeOf(wp)
GetWindowPlacement_(WindowID(0),@wp)
anim = wp\showCmd

ButtonGadget(1,10,10,80,25,"Test")

Repeat
  Select WaitWindowEvent()
     
    Case #PB_Event_CloseWindow
      Q = 1   
       
    Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
              anm\iMinAnimate = 0
              SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)           
              wp\showCmd = #SW_HIDE
              SetWindowPlacement_(WindowID(0),@wp)
              Delay(2000)
              anm\iMinAnimate = Animflag
              SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
              wp\showCmd = anim
              SetWindowPlacement_(WindowID(0),@wp)
               
        EndSelect
             
  EndSelect
Until Q = 1
Edit : modified for better performance

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 3:54 pm
by c4s
Thanks for your effort. I'm using Windows 8.1 (what do you use?) and with your new code the hiding of the taskbar tab is still animated. :(

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 3:59 pm
by RASHAD
Hi
I am using PB 5.21 x86-x64 - Windows 8.1 x64
Try the next
Be aware of the active window status in the task bar

Code: Select all


Global Animflag

Procedure HideFromTaskBar2(hWnd, Flag)
  Protected TBL.ITaskbarList

  CoInitialize_(0)
  If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList, @TBL) = #S_OK
    TBL\HrInit()
    If Flag
      TBL\DeleteTab(hWnd)
    Else
      TBL\AddTab(hWnd)
    EndIf
    TBL\Release()
  EndIf
  CoUninitialize_()

  DataSection
    CLSID_TaskBarList:
    Data.l $56FDF344
    Data.w $FD6D, $11D0
    Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
    IID_ITaskBarList:
    Data.l $56FDF342
    Data.w $FD6D, $11D0
    Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
  EndDataSection
EndProcedure

OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
anm.ANIMATIONINFO
anm\cbSize = SizeOf(anm)
SystemParametersInfo_(#SPI_GETANIMATION, SizeOf(anm), @anm, 0)
Animflag = anm\iMinAnimate

ButtonGadget(1,10,10,80,25,"Test")

Repeat
  Select WaitWindowEvent()
     
    Case #PB_Event_CloseWindow
      Q = 1   
       
    Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
              anm\iMinAnimate = 0
              SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
              HideFromTaskBar2(WindowID(0), 1)
              ShowWindow_(WindowID(0),#SW_HIDE)
              Delay(2000)
              anm\iMinAnimate = Animflag
              SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
              HideFromTaskBar2(WindowID(0), 0)
              ShowWindow_(WindowID(0),#SW_SHOW) 
               
        EndSelect
             
  EndSelect
Until Q = 1

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 4:32 pm
by c4s
Thanks. I already tried that and it didn't work. There simply doesn't seem to be a way to disable the taskbar tab animation?! I've searched for several hours and didn't find anything programming related - just some Windows system settings to disable it altogether (apparently it has to do with the menu animation)...

I created a small video with your latest code just to make sure that you know which animation I mean, it's here: http://videobam.com/DEgjU (Sorry for the ad-filled website - make sure that you don't click on any of it only on "close to play"!)

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 4:42 pm
by RASHAD
@c4s
Go to control panel - system -Advanced system settings - Advanced - settings
Disable :
Animate windows when minimizing and maxmizing
Animations in the taskbar

Then make a comarison with any of the previous solutions

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sat Jan 18, 2014 9:15 pm
by RASHAD
Using DWMWA as you mentioned

Code: Select all

#DWMWA_TRANSITIONS_FORCEDISABLED = 3

OpenWindow(0, 0, 0, 300, 300, "Window TRANSITIONS Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)

ButtonGadget(0, 5, 5, 64, 24, "TEST")

Repeat
   Event = WaitWindowEvent()
   
   Select Event
      Case #PB_Event_Gadget
         Select EventGadget()
            Case 0
               Disable = 1
               If OpenLibrary(0, "dwmapi.dll")      
                    CallFunction(0, "DwmSetWindowAttribute", WindowID(0), #DWMWA_TRANSITIONS_FORCEDISABLED, @Disable, SizeOf(Long))      
                    CloseLibrary(0)
              EndIf
              HideWindow(0,1)
         EndSelect
   EndSelect
   
Until Event = #PB_Event_CloseWindow

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sun Jan 19, 2014 10:36 am
by c4s
RASHAD wrote:Go to control panel - system -Advanced system settings - Advanced - settings
Disable :
Animate windows when minimizing and maxmizing
Animations in the taskbar
Yes, that's the problem: My window should hide without animation (of the taskbar tab) no matter if the above settings are enabled or not.

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sun Jan 19, 2014 10:53 am
by RASHAD
Hi c4s
I will not give up until you say so :P
Did you tested my previous post ?

Code: Select all

Global Animflag

OpenWindow(1, 0, 0, 0, 0, "Not Needed", #PB_Window_Invisible)
OpenWindow(0,0,0,100,100,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
SetWindowLongPtr_(WindowID(0),#GWL_HWNDPARENT,WindowID(1))
anm.ANIMATIONINFO
anm\cbSize = SizeOf(anm)
SystemParametersInfo_(#SPI_GETANIMATION, SizeOf(anm), @anm, 0)
Animflag = anm\iMinAnimate

ButtonGadget(0, 5, 5, 64, 24, "TEST")

Repeat
   Event = WaitWindowEvent()
   
   Select Event
      Case #PB_Event_Gadget
         Select EventGadget()
            Case 0
                anm\iMinAnimate = 0
                SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
                HideWindow(0,1)
                Delay(2000)                
                HideWindow(0,0)
                anm\iMinAnimate = Animflag
                SystemParametersInfo_(#SPI_SETANIMATION, SizeOf(anm), @anm, 0)
         EndSelect
   EndSelect
   
Until Event = #PB_Event_CloseWindow

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sun Jan 19, 2014 1:25 pm
by c4s
RASHAD wrote:Hi c4s
I will not give up until you say so :P
:D

I tried all your codes. Unfortunately none do what I want/need. I don't want to remove the taskbar tab as long as the window is opened - I just have to find a way to deal with the rather long animation. Possible solutions I came up with: Either disable it for my window (which doesn't seem to work), or at least find out how long it takes so I can work around it.

But even finding out the delay seems to be impossible! I searched through the registry if any key has the data "250" or "260" - because I think it's how long it takes - but found none that are related. I also searched through the documentation on MSDN and found nothing... Any ideas?

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sun Jan 19, 2014 1:36 pm
by RASHAD

Code: Select all

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Ta‌​skBarAnimations 

Re: Window hiding animation - Delay? / Possible to disable?

Posted: Sun Jan 19, 2014 3:38 pm
by c4s
RASHAD wrote:

Code: Select all

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Ta‌​skBarAnimations 
Thanks, I'm already aware of that one. It only tells me if the animation is enabled but the delay/time it takes. :cry: