Jump to content

Window Smooth Resize


this
 Share

Recommended Posts

First UDF I've posted on here. Sorry if I screwed anything up massively in advance.

I've been working with Javascript a lot recently and noticed the use of these transitions and decided to attempt to port them to AutoIt.

Adapted from Robert Penner Easing equations <http://www.robertpenner.com/easing/>

Flickers if used on an AutoIt GUI :/

;===============================================================================
; Name:         :   _WinSineInOutResize
; Description:      :   Smoothly resizes GUI based on a sine wave.
; Parameter(s):     :   $hWnd       -   GUI Handle
;                   $iResizeTo  -   Size to resize to
;                   $iDuration  -   Amount of time to run the resize for
;                   $iFPS       -   Frames/Second. Amount of times to run the effect in one second.
; Requirement:      :   None
; Return Value(s):  :   True    -   Success
;                   False   -   Invalid GUI handle
; User CallTip:     :
; Author(s):        :   this
; Note(s):          :   Adapted from Robert Penner Easing equations <http://www.robertpenner.com/easing/>.
;===============================================================================

Global Const $pi = ATan(1) * 4

Func _WinSineInOutResize($hWnd, $iResizeTo = 0, $iDuration = 500, $iFPS = 50)
    If Not IsHWnd($hWnd) Or Not WinExists($hWnd) Then
        ConsoleWriteError("Invalid Window handle for _GUI_SineResize 1st parameter" & @CRLF)
        SetError(1)
        Return False
    Else
        $aSize = WinGetPos($hWnd)
        $oTimer = TimerInit()
        While 1
            WinMove($hWnd, "", Default, Default, Default, -(($iResizeTo - $aSize[3]) / 2) * (Cos($pi * (TimerDiff($oTimer) / $iDuration)) - 1) + $aSize[3], 1)
            If TimerDiff($oTimer) > $iDuration Then
                WinMove($hWnd, "", Default, Default, Default, $iResizeTo)
                ExitLoop
            EndIf
            Sleep(1000 / $iFPS)
        WEnd
    EndIf
EndFunc   ;==>_WinSineInOutResize
UDFsWinSineInOutResize () - Resize a window smoothly based on a sine curve.
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...