Syntax
Success = StopAnimation(Object, ID, Flags=#Null)Description
Stops a specific animation loop (or all animations) that was previously started on a ProGUI object (Window or Widget) using StartAnimation().
Parameters
Object
The handle of the ProGUI Window or Widget on which the animation is
running.
ID
The integer identifier of the animation to stop. This must match the ID
provided to or returned by the corresponding StartAnimation() call. If
#PG_Any is passed, all animations running on the specified
Object will be stopped.
Flags (optional)
Flags modifying the stop behavior. Default is #Null.
#PG_Animation_Kill : Immediately removes the animation without dispatching the final `#PG_Event_Animate_End` event. By default (without this flag), the animation state is set to `#PG_Event_Animate_End` and it will dispatch the end event in the next animation loop cycle before being removed.
Return Value
Returns #True if the animation was found and
successfully stopped (or queued to be stopped). Returns
#False if the Object handle is invalid or no
animation with the specified ID was found running on that
object.
Remarks
Stopping an animation prevents further
#PG_Event_Animate_Update events from being dispatched for
that animation ID. By default, it will trigger a final
#PG_Event_Animate_End event in the next animation loop
cycle. If the #PG_Animation_Kill flag is provided, the
animation is deleted immediately without the end event. It's generally
good practice to ensure the animated property reaches its final intended
state when stopping an animation manually, if required.
Example
IncludeFile "ProGUI_PB.pbi"
Global MyAnimationID
Procedure AnimateHandler(Object, EventType, *EventData.PG_EventAnimate, *UserData)
Static Counter
Select *EventData\state
Case #PG_Event_Animate_Start
Debug "Animation started (will run indefinitely)"
Counter = 0
Case #PG_Event_Animate_Update
Counter + 1
Debug "Animation Update #" + Str(Counter)
; Stop the animation after 50 updates
If Counter >= 50
Debug "Stopping animation..."
StopAnimation(Object, *EventData\id)
EndIf
Case #PG_Event_Animate_End
Debug "Animation explicitly stopped or completed"
EndSelect
EndProcedure
StartProGUI()
MyWindow = CreateWindow(0, 0, 300, 200, "StopAnimation Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Animate, @AnimateHandler())
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
; Start an indefinite animation (Duration=0)
MyAnimationID = StartAnimation(MyWindow, #PG_Any, 0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
StartAnimation, AnimationGetCurrentTime, #PG_Event_Animate
Supported OS
Windows, Linux