Sign in to follow this  
Followers 0
LiquidNitrogen

AnimateControl() UDF

7 posts in this topic

#1 ·  Posted (edited)

This UDF i Created gives a Control an Animated Entrance.

; #FUNCTION# ==========================================================================
; Function......: AnimateControl($hWnd, $iHandle [,$iAnimate [,$iSpeed]])
; Author........: ReaperX
; Description...: Gives a Control an Animated Entrance.
; $hWnd -> Handle to the Current GUI Window
; $iHandle -> Handle to the Control to Animate
; $iAnimate -> Entrance Animation to Use. Options:
;                                                1 = Slide in from left (Default)
;                                                2 = Slide in from right
;                                                3 = Slide in from top
;                                                4 = Slide in from bottom
; $iSpeed -> Speed of the Entrance. Options:
;                                          0 = Fast
;                                          1 = Slow (Default)
; @Error -> -1 = Invalid Parameter for $iAnimate
;           -2 = Invalid Parameter for $iSpeed
; ======================================================================================

Func AnimateControl($hWnd, $iHandle, $iAnimate = 1, $iSpeed = 1)
Local $iPos, $iWinSize
If $iAnimate > 4 Or $iAnimate < 1 Or Not StringIsAlNum($iAnimate) Then
  SetError(-1)
  ConsoleWrite("Invalid Parameter for $iAnimate in _WinAPI_AnimateControl()." & @CRLF)
  Exit
EndIf
If $iSpeed > 1 Or $iSpeed < 0 Or Not StringIsAlNum($iSpeed) Then
  SetError(-2)
  ConsoleWrite("Invalid Parameter for $iSpeed in _WinAPI_AnimateControl()." & @CRLF)
  Exit
EndIf
GUISetState()
$iPos = ControlGetPos(WinGetTitle($hWnd), "", $iHandle)
$iWinSize = WinGetClientSize(WinGetTitle($hWnd))
;Slide in from Left
If $iAnimate = 1 Then
  For $i = -40 To $iPos[0]
   GUICtrlSetPos($iHandle, $i, $iPos[1])
   Sleep($iSpeed)
  Next
  Return
EndIf
;Slide in from Right
If $iAnimate = 2 Then
  For $i = $iWinSize[0] To $iPos[0] Step -1
   GUICtrlSetPos($iHandle, $i, $iPos[1])
   Sleep($iSpeed)
  Next
  Return
EndIf
;Slide in from Top
If $iAnimate = 3 Then
  For $i = 0 To $iPos[1]
   GUICtrlSetPos($iHandle, $iPos[0], $i)
   Sleep($iSpeed)
  Next
  Return
EndIf
;Slide in from Bottom
If $iAnimate = 4 Then
  For $i = $iWinSize[1] + 30 To $iPos[1] Step -1
   GUICtrlSetPos($iHandle, $iPos[0], $i)
   Sleep($iSpeed)
  Next
  Return
EndIf
EndFunc   ;==>AnimateControl
Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites



Just for the record, _WinAPI_* functions wrap the WINdows API... This is going to create some confusion with the actual winapi function AnimateWindow. If you search the forum I'm sure you'll find examples of using that function.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yeah... I dont know why i chose _WinAPI. Sorry. I Changed it.

Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites

ReaperX Can U give me Sample from U'r UDF ..??

I New In AutoIt. I want Learn for everything in AutoIt..

Thank's..

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

not working as expected

#include <GUIConstantsEx.au3>

Opt( "TrayIconDebug", 1 )

$hWin = GUICreate(@ScriptName)
$iLbl = GUICtrlCreateLabel('This is a Test', 10, 10)
GUICtrlSetState( -1, $GUI_HIDE )
GUISetState()

AnimateControl($hWin, $iLbl, 4, 100)

While GUIGetMsg() <> -3
Sleep(10)
WEnd

; #FUNCTION# ==========================================================================
; Function......: AnimateControl($hWnd, $iHandle [,$iAnimate [,$iSpeed]])
; Author........: ReaperX/ Modified - Phoenix XL
; Description...: Gives a Control an Animated Entrance.
; $hWnd -> Handle to the Current GUI Window
; $iHandle -> Handle to the Control to Animate
; $iAnimate -> Entrance Animation to Use. Options:
; 1 = Slide in from left (Default)
; 2 = Slide in from right
; 3 = Slide in from top
; 4 = Slide in from bottom
; $iSpeed -> Speed of the Entrance. Any number use as required
; @Error -> -1 = Invalid Parameter for $iAnimate
; -2 = Invalid Parameter for $iSpeed
; ======================================================================================

Func AnimateControl($hWnd, $iHandle, $iAnimate = 1, $iSpeed = 1)
Local $iPos, $iWinSize
If $iAnimate > 4 Or $iAnimate < 1 Or Not StringIsAlNum($iAnimate) Then
SetError(-1)
ConsoleWrite("Invalid Parameter for $iAnimate in _WinAPI_AnimateControl()." & @CRLF)
Return
EndIf
If $iSpeed < 0 Or Not IsNumber($iSpeed) Then
SetError(-2)
ConsoleWrite("Invalid Parameter for $iSpeed in _WinAPI_AnimateControl()." & @CRLF)
Return
EndIf
;GUISetState()
$iPos = ControlGetPos($hWnd, "", $iHandle)
$iWinSize = WinGetClientSize(WinGetTitle($hWnd))
;Slide in from Left
If $iAnimate = 1 Then
GUICtrlSetPos($iHandle, -40, $iPos[1])
GUICtrlSetState( $iHandle, $GUI_SHOW )
For $i = -40 To $iPos[0]
GUICtrlSetPos($iHandle, $i, $iPos[1])
Sleep((1 / $iSpeed) * 30)
Next
Return
EndIf
;Slide in from Right
If $iAnimate = 2 Then
GUICtrlSetPos($iHandle, $iWinSize[0], $iPos[1])
GUICtrlSetState( $iHandle, $GUI_SHOW )
For $i = $iWinSize[0] To $iPos[0] Step -1
GUICtrlSetPos($iHandle, $i, $iPos[1])
Sleep((1 / $iSpeed) * 30)
Next
Return
EndIf
;Slide in from Top
If $iAnimate = 3 Then
GUICtrlSetPos($iHandle, $iPos[0], 0)
GUICtrlSetState( $iHandle, $GUI_SHOW )
For $i = 0 To $iPos[1]
GUICtrlSetPos($iHandle, $iPos[0], $i)
Sleep((1 / $iSpeed) * 30)
Next
Return
EndIf
;Slide in from Bottom
If $iAnimate = 4 Then
GUICtrlSetPos($iHandle, $iPos[0], $iWinSize[1] + 30)
GUICtrlSetState( $iHandle, $GUI_SHOW )
For $i = $iWinSize[1] + 30 To $iPos[1] Step -1
GUICtrlSetPos($iHandle, $iPos[0], $i)
Sleep((1 / $iSpeed) * 30)
Next
Return
EndIf
EndFunc   ;==>AnimateControl

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

not working as expected :bye:

Thank's PhoenixXL

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