Jump to content

Is there a way to disable the windows "fade effect" for a particular GUI


jpomalley
 Share

Recommended Posts

Hi all,

Does anyone know if there is a way to disable the Windows "fade effect" that occurs when a window appears or disappears?

It is possible for a user to disable visual effects in windows in general through the system properties > performance settings, but I am interested just in fixing it for a particular window that pops up in my app.

I would like it to appear and disappear instantaneously, snapping in and out, out of nowhere, rather than the short (maybe 300 ms?) fade in/fade out effect that windows has.

Thanks for any tips

JP

Link to comment
Share on other sites

Do you mean something like this here?

;Coded by UEZ build 2019-02-05
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>

Global Const $iState = _WinAPI_GetGUIMinMaxAnim()

If $iState Then _WinAPI_SetGUIMinMaxAnim(0)

Global $hGUI = GUICreate("No min/max GUI anim")
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

If $iState Then _WinAPI_SetGUIMinMaxAnim(1)


Func _WinAPI_SetGUIMinMaxAnim($bAnim = 0)
    $bAnim = ($bAnim < 0) ? 0 : ($bAnim > 1) ? 1 : $bAnim
    Local Const $SPIF_SENDCHANGE = 0x02, $SPI_SETANIMATION = 0x0049
    Local $tANIMATIONINFO = DllStructCreate("uint cbSize;int iMinAnimate")
    $tANIMATIONINFO.cbSize = DllStructGetSize($tANIMATIONINFO)
    $tANIMATIONINFO.iMinAnimate = $bAnim
    Return _WinAPI_SystemParametersInfo($SPI_SETANIMATION, 0, $tANIMATIONINFO, $SPIF_SENDCHANGE)
EndFunc   ;==>_WinAPI_SetGUIMinMaxAnim

Func _WinAPI_GetGUIMinMaxAnim()
    Local Const $SPIF_SENDCHANGE = 0x02, $SPI_GETANIMATION = 0x0048
    Local $tANIMATIONINFO = DllStructCreate("uint cbSize;int iMinAnimate")
    $tANIMATIONINFO.cbSize = DllStructGetSize($tANIMATIONINFO)
    _WinAPI_SystemParametersInfo($SPI_GETANIMATION, $tANIMATIONINFO.cbSize, $tANIMATIONINFO)
    Return $tANIMATIONINFO.iMinAnimate
EndFunc   ;==>_WinAPI_GetGUIMinMaxAnim

 

Tested only on Win10.

 

Edit: it seems that this function influences all GUI behavior and not only the created GUI. I can remember that there is a code only for the created GUI but I cannot find it at the moment.

Edited by UEZ
Added _WinAPI_GetGUIMinMaxAnim()

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

for your own GUI, use WinSetTrans(0) to make the window invisible before it gets minimized/restored (i.e. before the effect in question happens), and WinSetTrans(255) after.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

UEZ, your code worked perfectly, thanks so much. As you noted it affects all GUIs and not just the one being created so that is a limitation. I guess the solution to that would be to retrieve the state of the windows settings that the script affects before changing them, make the GUI, then restore the settings. Maybe do this again when the window is being dismissed. A little brute force but would work I think.

Orbs, would this actually bring up the window faster? Users are going to be repeatedly running this tool throughout the day and I want to make it as snappy as possible, shaving off even 1/3 of a second from start and quit by removing the fade-in and fade-out. I will give that a try (WinSetTrans(0), and WinSetTrans(255)). It seems to me that that would remove the fade effect but not actually shave off 2/3 a second from the launch-use-quit cycle. However even a perception of being faster may improve the UX. :) So it may be worth doing nonetheless.

Correct me if Im wrong but it seems to me that the UEZ method may actually shave 2/3 of a second off the total use experience per activation, whereas the WinSetTrans method may (hopefully) make it feel snappier potentially but not actually shave off time. Am I correct?

Thanks

JP

Link to comment
Share on other sites

2 hours ago, jpomalley said:

UEZ, your code worked perfectly, thanks so much. As you noted it affects all GUIs and not just the one being created so that is a limitation. I guess the solution to that would be to retrieve the state of the windows settings that the script affects before changing them, make the GUI, then restore the settings. Maybe do this again when the window is being dismissed. A little brute force but would work I think.

I updated the code from post#2.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...