Sign in to follow this  
Followers 0
dansxmods

_Animate_Window_UDF

13 posts in this topic

Just a quick UDF that I threw together because I can see myself using these functions alot.

Hope you all like it.

Attached files at bottom of post.

The UDF.

Const $blend_in = 0x00080000
Const $blend_out = 0x00090000
Const $roll_up = 0x00020008
Const $roll_down = 0x00020004
Const $roll_left = 0x00020002
Const $roll_right = 0x00020001
Const $slide_up = 0x00040008
Const $slide_down = 0x00040004
Const $slide_left = 0x00040002
Const $slide_right = 0x00040001
Const $roll_ddl = BitOR($roll_down, $roll_left)
Const $roll_ddr = BitOR($roll_down, $roll_right)
Const $roll_dul = BitOR($roll_up, $roll_left)
Const $roll_dur = BitOR($roll_up, $roll_right)
Const $slide_ddl = BitOR($slide_down, $slide_left)
Const $slide_ddr = BitOR($slide_down, $slide_right)
Const $slide_dul = BitOR($slide_up, $slide_left)
Const $slide_dur = BitOR($slide_up, $slide_right)
Const $explode = 0x00020010
Const $implode = 0x00010010
Const $anim_hide = 0x00010000


; #Function;================================================================================================


; Name.................; _Animate_Window
; Description..........; Animates the gui that you create and sets the state.
; Syntax...............; _Animate_Window($hHwnd, $iTime, $sAction, [$iHide])
; Paramaters...........; $hHwnd - The handle of the GUI
;                       $iTime  - The time to run in Milliseconds
;                       $sAction  - The way you want GUI to be animated:
;                       |$blend_in   = Fades in
;                        |$blend_out    = Fades out
;                        |$roll_up    = Rolls upward
;                        |$roll_down    = Rolls downward
;                        |$roll_left    = Rolls in leftward
;                        |$roll_right   = Rolls in rightward
;                       |$roll_ddl   = Rolls diagonally down left
;                       |$roll_ddr   = Rolls diagonally down right
;                       |$roll_dul   = Rolls diagonally up left
;                       |$roll_dur   = Rolls diagonally up right
;                       |$slide_up   = Slides upward
;                       |$slide_down   = Slides downward
;                       |$slide_left   = Slides leftward
;                       |$slide_right  = Slides rightward
;                       |$slide_ddl = Slides diagonally down left
;                       |$slide_ddr = Slides diagonally down right
;                       |$slide_dul = Slides diagonally up left
;                       |$slide_dur = Slides diagonally up right
;                       |$explode     = Expands outward
;                       |$implode     = Collapses inward
;                       
;                       $iHide  - [Optional]Specifies if it will hide the window:
;                       |0 = shows the window, the Default
;                       |1 = Does the opposite and Hides the window on all but $blend, $explode and $implode
; Return Values........; None
; Author...............; Daniel Fielding (dansxmods)
; Modified.............;
; Remarks..............; Don't set the hide paramater on $blend_in, $blend_out, $explode and $implode. 
;                       Ensure you use GUISetState() after using this function or the controls on the GUI will not respond.
; Related..............;
; Link.................; http://msdn.microsoft.com/en-us/library/ms632669.aspx
; Example..............; Yes
;
;;================================================================================================

==========


Func _Animate_Window($hHwnd, $iTime, $sAction, $iHide = 0)
If $iHide = 1 Then
    $sAction = BitOR($sAction, $anim_hide)
EndIf
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hHwnd, "int", $iTime, "long", $sAction)

EndFunc;==> _Animate_Window()

The example.

#include <_Animate_Window_UDF.au3>
#include <GUIConstantsEx.au3>

; All examples below are set to take 0.5 of a second.

$gui = GUICreate("Hello World", -1, -1, -1, -1)
$button = GUICtrlCreateButton("Click Me!", 50, 50, -1, -1)

_Animate_Window($gui, 500, $Blend_in);Fades in $gui
GUISetState(@SW_SHOW, $gui)
While 1
    $GuiMSG = GUIGetMsg()
    Select
    Case $GuiMSG = $GUI_EVENT_CLOSE 
        Exit
    Case $GuiMSG = $button
        _Animate_Window($gui, 500, $roll_ddr, 1);Rolls $gui diagonally down right and hides
        GUISetState(@SW_HIDE, $gui)
        ExitLoop
    
    EndSelect
WEnd


_Animate_Window($gui, 500, $slide_up);Slides $gui up vertically
GUISetState(@SW_SHOW, $gui)
While 1 
    $GuiMSG = GUIGetMsg()
    Select
    Case $GuiMSG = $GUI_EVENT_CLOSE 
        Exit
    Case $GuiMSG = $button
        _Animate_Window($gui, 500, $implode);Collapses $gui inwards, Doesn't need the hide paramater because it is written in to $implode.
        GUISetState(@SW_HIDE, $gui)
        ExitLoop
    EndSelect
WEnd


_Animate_Window($gui, 500, $roll_left);Rolls in leftward
GUISetState(@SW_SHOW, $gui)
While 1 
    $GuiMSG = GUIGetMsg()
    Select
    Case $GuiMSG = $GUI_EVENT_CLOSE 
        Exit
    Case $GuiMSG = $button
        _Animate_Window($gui, 500, $blend_out);Fades out, Doesn't need the hide paramater because it is written in to $blend_out.
        GUISetState(@SW_HIDE, $gui)
        Exit
    EndSelect
WEnd

_Animate_Window.au3

_Animate_Window_UDF.au3

Share this post


Link to post
Share on other sites



What is different from other scripts who can do that? :)


When the words fail... music speaks

Share this post


Link to post
Share on other sites
AnimateWindow UDF from 2005 is just one example of it. It has been made several times with only minor changes.

Share this post


Link to post
Share on other sites

Doesn't work on Vista.

Share this post


Link to post
Share on other sites

This version by Gary Frost works fine on Vista 32 SP1:

; Declare AnimateWindow constants
Global Const $AW_FADE_IN  = 0x00080000
Global Const $AW_FADE_OUT = 0x00090000
Global Const $AW_EXPLODE  = 0x00040010
Global Const $AW_IMPLODE  = 0x00050010
Global Const $AW_SLIDE_IN_LEFT  = 0x00040001
Global Const $AW_SLIDE_OUT_LEFT   = 0x00050002
Global Const $AW_SLIDE_IN_RIGHT   = 0x00040002
Global Const $AW_SLIDE_OUT_RIGHT  = 0x00050001
Global Const $AW_SLIDE_IN_TOP    = 0x00040004
Global Const $AW_SLIDE_OUT_TOP  = 0x00050008
Global Const $AW_SLIDE_IN_BOTTOM  = 0x00040008
Global Const $AW_SLIDE_OUT_BOTTOM = 0x00050004
Global Const $AW_DIAG_SLIDE_IN_TOPLEFT    = 0x00040005
Global Const $AW_DIAG_SLIDE_OUT_TOPLEFT  = 0x0005000A
Global Const $AW_DIAG_SLIDE_IN_TOPRIGHT  = 0x00040006
Global Const $AW_DIAG_SLIDE_OUT_TOPRIGHT    = 0x00050009
Global Const $AW_DIAG_SLIDE_IN_BOTTOMLEFT   = 0x00040009
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMLEFT  = 0x00050006
Global Const $AW_DIAG_SLIDE_IN_BOTTOMRIGHT  = 0x0004000A
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = 0x00050005

; #FUNCTION# ================================================================
; Name............: _WinAnimate
; Description ....: Animates windows by sliding, fading or exploding in/out
; Syntax..........: _WinAnimate($v_gui, $i_mode, [$i_duration])
; Parameters .....: $v_gui      -> Either handle or title of window to animate
;                  $i_mode      -> $AW constant from above
;                  $i_duration  -> Speed of animation (higher = slower)
; Requirement(s)..: v3.2.12.1 or higher
; Return values ..: Success:    Returns 1
;                  Failure: Returns 0, Error 1 = DLL call fail, Error 2 = OS version incapable
; Author .........: Gary Frost
; Example.........; Yes
;=========================================================================

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

And from 3.3.0.0 onwards, you do not even need the OS check.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

This version by Gary Frost works fine on Vista 32 SP1:

; Declare AnimateWindow constants
Global Const $AW_FADE_IN  = 0x00080000
Global Const $AW_FADE_OUT = 0x00090000
Global Const $AW_EXPLODE  = 0x00040010
Global Const $AW_IMPLODE  = 0x00050010
Global Const $AW_SLIDE_IN_LEFT  = 0x00040001
Global Const $AW_SLIDE_OUT_LEFT   = 0x00050002
Global Const $AW_SLIDE_IN_RIGHT   = 0x00040002
Global Const $AW_SLIDE_OUT_RIGHT  = 0x00050001
Global Const $AW_SLIDE_IN_TOP    = 0x00040004
Global Const $AW_SLIDE_OUT_TOP  = 0x00050008
Global Const $AW_SLIDE_IN_BOTTOM  = 0x00040008
Global Const $AW_SLIDE_OUT_BOTTOM = 0x00050004
Global Const $AW_DIAG_SLIDE_IN_TOPLEFT    = 0x00040005
Global Const $AW_DIAG_SLIDE_OUT_TOPLEFT  = 0x0005000A
Global Const $AW_DIAG_SLIDE_IN_TOPRIGHT  = 0x00040006
Global Const $AW_DIAG_SLIDE_OUT_TOPRIGHT    = 0x00050009
Global Const $AW_DIAG_SLIDE_IN_BOTTOMLEFT   = 0x00040009
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMLEFT  = 0x00050006
Global Const $AW_DIAG_SLIDE_IN_BOTTOMRIGHT  = 0x0004000A
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = 0x00050005

; #FUNCTION# ================================================================
; Name............: _WinAnimate
; Description ....: Animates windows by sliding, fading or exploding in/out
; Syntax..........: _WinAnimate($v_gui, $i_mode, [$i_duration])
; Parameters .....: $v_gui      -> Either handle or title of window to animate
;                  $i_mode      -> $AW constant from above
;                  $i_duration  -> Speed of animation (higher = slower)
; Requirement(s)..: v3.2.12.1 or higher
; Return values ..: Success:    Returns 1
;                  Failure: Returns 0, Error 1 = DLL call fail, Error 2 = OS version incapable
; Author .........: Gary Frost
; Example.........; Yes
;=========================================================================

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

And from 3.3.0.0 onwards, you do not even need the OS check.

M23

Ugh...only the fade in and out work.

Share this post


Link to post
Share on other sites

Sorry to hear that. I am afraid there must be something wrong with your setup. All the functions work fine for me - and everyone I know who is using the app I wrote including this very UDF on their Vista and XP machines.

I am afraid I have no suggestions as to what might be the cause. This is the example that Gary Frost included with his UDF:

; Example

$hwnd = GUICreate("AnimateWindow - Demo", 300, 300)
GUISetBkColor(0xFFFF00)
$RetValue = _WinAnimate($hwnd, $AW_FADE_IN)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_FADE_OUT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_EXPLODE)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_IMPLODE)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_LEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_LEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_RIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_RIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_TOP)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_TOP)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_BOTTOM)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_BOTTOM)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_TOPLEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_TOPLEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_TOPRIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_TOPRIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_BOTTOMLEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_BOTTOMLEFT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_BOTTOMRIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)
Sleep(1500)
$RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT)
ConsoleWrite($RetValue & "   " & "Err: " & @error & "   " & "Ext: " & @extended & @CRLF)

Exit

Perhaps you might like to try that to see if it works any better. If you still have problems, I would suggest opening a thread in the GUI help forum rather than continuing here.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I wrote one too

; Demo

#include <GUIConstants.au3>
Dim $repeat = 1
$hwnd = GUICreate("XSkin Animate", 300, 300)

$ret = XSkinAnimate($hwnd, 1, $repeat)
Sleep(2000)

While $repeat <= 28 ;*********** will error - for testing
    $repeat += 1
    XSkinAnimate($hwnd, "", $repeat)
   
    Sleep(1000)
   
    $repeat += 1
    XSkinAnimate($hwnd, "", $repeat)
    Sleep(1000)
WEnd




Func XSkinAnimate($Xwnd, $Xstate = 1, $Xstyle = 0, $Xtrans = 0, $Xspeed = 1000)
    ; $Xstate  - 1 = Show, 2 = Hide, "" = No State Set
    ; $Xstyle - 1=Fade, 3=Explode, 5=L-Slide, 7=R-Slide, 9=T-Slide, 11=B-Slide, 13=TL-Diag-Slide, 15=TR-Diag-Slide, 17=BL-Diag-Slide, 19=BR-Diag-Slide
    Local $Xpick = StringSplit('80000,90000,40010,50010,40001,50002,40002,50001,40004,50008,40008,50004,40005,5000a,40006,50009,40009,50006,4000a,50005', ",")
    If Not WinExists($Xwnd) Then XSkinAnError("XSkinAnimate, $Xwnd - Window not found   ")
    If $Xstyle > $Xpick[0] Then XSkinAnError("XSkinAnimate, $Xstyle max is 19  ")
    If $Xstyle <> 0 Then Local $ret = DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Xwnd, "int", $Xspeed, "long", "0x000" & $Xpick[$Xstyle])
    If $Xtrans <> 0 Then WinSetTrans($Xwnd, "", $Xtrans)
    If $Xstate = 1 Then GUISetState(@SW_SHOW, $Xwnd)
    If $Xstate = 2 Then GUISetState(@SW_HIDE, $Xwnd)
    If $Xstyle <> 0 Then Return $ret
EndFunc   ;==>XSkinAnimate

Func XSkinAnError($XE_msg)
    MsgBox(262208, "XSkin Error", $XE_msg, 5)
    Exit
EndFunc   ;==>XSkinAnError

The loop will error, that is part of the Demo

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I'm with GoldFishCrackers on this one. Vista Aero and AnimateWindow don't work well together.

Vista Ultimate SP1 32-bit

HP dv8000t laptop, GeForce 7400 Go

Fade in works OK, but on fade out Aero is disabled and the titlebar goes to Vista's standard theme. All the others exhibit the same weird flickering and not-workingness of GoldFishCrackers' video.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I didn't realise that this had been posted before. I did a search for window animate but not for winanimate. Oh well there you go. I will use mine.

Just tested it on my Laptop that has Vista Bussiness, it works ok. Does Leave the border while doing the animation.

Edited by dansxmods

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

erorr :)

post-44581-1232403129_thumb.jpg

Edited by sisu

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

For the love....learn to read an error message please.

Edited by wraithdu

Share this post


Link to post
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
Sign in to follow this  
Followers 0