Jump to content

GUI Fade In


j0rg3
 Share

Recommended Posts

I was playing around and decided to create a form that would fade in. The best I have been able to do is GUICreate the form, GUISetState to hide it and then WinSetTrans to make it transparent.

Then I GuiSetState to show the form and I loop WinSetTrans to bring it in.

For a script that does nothing more :) , it frustrates me that my GUI form flickers in first. I was thinking of creating a tiny GUI and then resizing it while hidden but I don't know how to resize it and I'm hoping there is a better way.

Any advice?

Thanks!

Link to comment
Share on other sites

Hi,

there are more possibilities of fading.

But ...

#include <GuiConstants.au3>

Global Const $AW_FADE_IN = 0x00080000;fade-in
Global Const $AW_FADE_OUT = 0x00090000;fade-out

$MAINGUI = GUICreate('Some Window', 200, 100)
$BUTTON1 = GUICtrlCreateButton('FadeOut', 10, 20, 180, 30)
$BUTTON2 = GUICtrlCreateButton('FadeIn', 10, 55, 180, 30)
GUISetState()
$GUI2 = GUICreate('Some Window2', 200, 100,0,0)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $BUTTON1
            _WinAnimate($GUI2, $AW_FADE_OUT)
        Case $msg = $BUTTON2
            _WinAnimate($GUI2, $AW_FADE_IN)
    EndSelect
WEnd

Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000)
    If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Then
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode)
        Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
        If $ai_gle[0] <> 0 Then
            SetError(1)
            Return 0
        EndIf
        Return 1
    EndIf
EndFunc;==> _WinAnimate()

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thanks rasim and Xenobiologist!

It turns out that a sloppy mistake was my whole problem. D'oh!

Although I have to play with the fade method provided by Xenobiologist; I've never seen it before.

Link to comment
Share on other sites

Hi,

there are more possibilities of fading.

But ...

#include <GuiConstants.au3>

Global Const $AW_FADE_IN = 0x00080000;fade-in
Global Const $AW_FADE_OUT = 0x00090000;fade-out

$MAINGUI = GUICreate('Some Window', 200, 100)
$BUTTON1 = GUICtrlCreateButton('FadeOut', 10, 20, 180, 30)
$BUTTON2 = GUICtrlCreateButton('FadeIn', 10, 55, 180, 30)
GUISetState()
$GUI2 = GUICreate('Some Window2', 200, 100,0,0)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $BUTTON1
            _WinAnimate($GUI2, $AW_FADE_OUT)
        Case $msg = $BUTTON2
            _WinAnimate($GUI2, $AW_FADE_IN)
    EndSelect
WEnd

Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000)
    If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Then
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode)
        Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
        If $ai_gle[0] <> 0 Then
            SetError(1)
            Return 0
        EndIf
        Return 1
    EndIf
EndFunc;==> _WinAnimate()

Mega

Truly Nice Work. I'm using it in most of my codes. Thanks Xenobiologist, wish though i could do the dll call thing seems so niiiice
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...