Syntax
Time = AnimationGetCurrentTime(Object, ID)
Description
Retrieves the elapsed time, in milliseconds, for a specific animation that is currently running on a ProGUI object (Window or Widget).
Parameters
Object
The handle of the ProGUI Window or Widget on which the animation is
running.
ID
The integer identifier of the animation whose current time is requested. This
must match the ID provided to or returned by the corresponding StartAnimation() call.
Return Value
Returns the elapsed time in milliseconds (Integer) since the animation with the specified `ID` started on the `Object`. Returns -1 if the `Object` handle is invalid or no animation with the specified `ID` is found running on that object (or animation ended).
Remarks
This function provides the same time information as the currentTime field within the
PG_EventAnimate structure received during an animation event.
It can be useful if you need to query the animation's progress outside of the standard event handler.
Example
IncludeFile "ProGUI_PB.pbi"
Global MyAnimationID
Global MyWindow
Procedure CheckAnimTime()
Protected CurrentTime
CurrentTime = AnimationGetCurrentTime(MyWindow, MyAnimationID)
If CurrentTime >= 0
Debug "Queried Animation Time: " + Str(CurrentTime) + "ms"
Else
Debug "Animation not found or finished."
EndIf
EndProcedure
StartProGUI()
MyWindow = CreateWindow(0, 0, 300, 200, "Get Animation Time")
If MyWindow
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
; Start a 5-second animation
MyAnimationID = StartAnimation(MyWindow, #PG_Any, 5000)
Debug "Started animation with ID: " + MyAnimationID
Repeat
Event = WaitWindowEvent(100) ; Wait with timeout to allow checking time
If Event = 0 ; Timeout occurred
CheckAnimTime()
If AnimationGetCurrentTime(MyWindow, MyAnimationID) = -1 ; Check if anim finished
Break
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
StartAnimation, StopAnimation, #PG_Event_Animate, PG_EventAnimate structure
Supported OS
Windows, Linux