Contains the definition of the base class for TTimer.

customtimer.pas defines TCustomTimer, the component used as the ancestor for timer components in the Lazarus Component Library (LCL).

Defines the base class for TTimer.

TCustomTimer is a TComponent descendant which specifies the base class for TTimer. TCustomTimer specifies the properties, methods, and events handlers used for timer classes in the LCL.

Use the Enabled property to indicate if the timer can be executed.

Use the Interval property to control the frequency of notification events from the executing timer class instance.

Use the OnTimer, OnStartTimer, and OnStopTimer event handlers to perform actions needed for the corresponding execution state in the timer class instance.

Do not create instances of TCustomTimer; use the TTimer descendant class in the ExtCtrls.pp unit.

TTimer
Procedure called when the timer interval has elapsed.

Timer is a private procedure called when the Interval for the timer has elapsed. Timer calls the DoOnTimer method to perform a notification using the OnTimer event (when assigned). Assign a procedure to the OnTimer event handler to perform actions needed when the Interval for the timer has elapsed.

If an exception occurs in DoOnTimer, the HandleException method in the CustomApplication singleton is called.

The Timer procedure is passed as an argument when the timer handle is created for the widget set in its UpdateTimer method.

Please note that the OnTimer event notification is not performed when Enabled contains False or when Interval contains the value 0 (zero).
TCustomApplication.HandleException CustomApplication
Sets the value for the Enabled property. True when the timer can be executed. Sets the value for the Interval property. The Value of the Interval property in milliseconds. Sets the event handler for the OnTimer property. TNotifyEvent handler signalled when the timer has expired. DoOnTimer signals the OnTimer event handler.

DoOnTimer is a protected virtual procedure used to signal the OnTimer event handler (when assigned). No actions are performed in DoOnTimer when OnTimer has not been assigned (contains Nil).

DoOnTimer is called from the Timer method when Enabled contains True and Interval contains a value greater than 0 (zero).

Assign a procedure to OnTimer to perform the actions required when the Interval for the timer has elapsed.

Set the value in Interval to control the frequency of timer event notifications.

Set Enabled to False to prevent execution of the timer.

Updates the Timer to reflect the current properties.

UpdateTimer is a protected virtual procedure used to update property values in the timer class instance. UpdateTimer calls KillTimer to stop the timer if it has been enabled and a widget set handle has been previously assigned for the class instance. The handle is recreated at run-time using the Timer method as a polling routine when Enabled contains True, when Interval contains a value greater than 0 (zero), and OnTimer has been assigned for the class instance. The handle is not recreated if the component is being freed, or when the component is Loaded using the LCL streaming mechanism.

UpdateTimer can raise an EOutOfResources exception with the message in SNoTimers if a missing or invalid handle is returned from the widget set class.

UpdateTimer signals the OnStartTimer event handler when it has been assigned for the class instance. The event handler is not signalled when it has not been assigned (contains Nil), Enabled contains False, or Interval contains the value 0 (zero).

UpdateTimer is called from the Loaded method when component streaming has been completed, and when the value in the OnTimer event handler is changed.

Raises an EOutOfResources exception with the message in SNoTimers if a missing or invalid handle is returned from the widget set class.

TComponent
Stops execution of the timer class instance.

KillTimer is a protected virtual procedure used to stop execution of the timer class instance. KillTimer ensures that a value widget set handle has been assigned for the timer class instance prior to freeing the handle and signalling the OnStopTimer event handler (when assigned). No actions are performed in the method if the widget set handle is not assigned or invalid.

KillTimer is called from the UpdateTimer method, and when the class instance is freed in the Destroy method.

Performs actions needed when LCL component streaming has been completed.

Loaded is an overridden method in TCustomTimer. It calls the inherited method on entry to remove csLoading from the ComponentState property.

Loaded calls UpdateTimer to re-create the timer handle and signal event event handlers as needed for the Enabled property in the timer. An EOutOfResources exception is raised (in UpdateTimer) if a timer handle cannot be allocated in the widgetset class.

TComponent.ComponentState
Create - constructor for TCustomTimer: calls inherited Create, sets up handle and initializes timer interval.

Create is the overridden constructor for the class instance. Create calls the inherited constructor using the component in AOwner as the owner for the class instance.

Create sets the default values for properties in the timer class instance; the timer Interval is set to 1000ms (1 second) and the Enabled property is set to True. The internal handle for the timer instance is set to the value which represents an invalid or unassigned handle (-1).

Change the value in the Interval property to alter the frequency of the timer notification.

Assigned an object procedure to the OnTimer event handler to perform actions needed when the timer Interval has expired.

TComponent.Create
Component which owns the timer class instance. Destructor for the timer class instance.

Destroy is the overridden destructor for the class instance. Destroy ensures that the OnTimer event handler is unassigned and Enabled is set to False before halting the timer by calling the KillTimer method.

Destroy calls the inherited destructor prior to exiting from the method.

Use the OnStopTimer event handler to perform actions needed when the timer is disabled or freed.

TComponent.Destroy
Indicates if the timer is ready to start.

Enabled is a Boolean property which controls the state for the timer class instance. When Enabled contains True the timer can be executed, and its OnTimer event handler is signalled when the Interval for the timer has elapsed. Changing the value in Enabled causes the UpdateTimer method to be called to set the current value for properties in the timer.

The Interval (in milliseconds) for timer notifications.

Interval is a Cardinal property which indicates the frequency (in milliseconds) for OnTimer event notifications during timer execution. The default value for the property is 1000 milliseconds (or 1 second).

Changing the value in Interval causes the UpdateTimer method to be called to update the values for properties in the timer class instance. Setting the value in Interval to 0 (zero) prevents the timer from allocating it handle and performing the OnStartTimer event handler when Enabled is changed to True.

Use Enabled to indicate if the timer can be executed.

Use the OnStartTimer, OnStopTimer, and OnTimer event handlers to perform actions needed for the corresponding execution states in the timer class instance.

Event handler signalled when the Interval for the timer has elapsed.

OnTimer is a TNotifyEvent property that implements the event handler signalled when the Interval for the timer has elapsed. The default value for the property is Nil as assigned in the constructor for the class instance.

Assign a TNotifyEvent procedure to the event handler to perform actions needed for the event notification. Setting the value in OnTimer causes the UpdateTimer method to be called to reflect the current values for the timer class instance.

Please note that OnTimer is not signalled during timer execution when Interval contains the value 0 (zero).

Use the OnStartTimer event handler to perform actions required when the timer is started by setting Enabled to True.

Use the OnStopTimer event handler to perform actions needed when the timer is halted by setting Enabled to False, or when calling the destructor for an executing timer class instance.

Event handler signalled when the timer is started.

OnStartTimer is a TNotifyEvent property that implements the event handler signalled when the timer class instance is started. Assign a TNotifyEvent procedure to the event handler to perform actions needed to reflect the change in the timer state. No actions are performed for the event notification when OnStartTimer is unassigned (contains Nil).

OnStartTimer is signalled from the UpdateTimer method when the value in the Enabled property is changed to True.

Please note that OnStartTimer is not signalled when Interval contains the value 0 (zero).

Use the OnStopTimer event handler to perform actions needed when the timer class instance is stopped (or freed during execution).

Use the OnTimer event handler to perform actions needed when the Interval for the timer has elapsed.

OnStopTimer - event handler for stopping the timer.

OnStopTimer is a TNotifyEvent property that implements the event handler signalled when the timer class instance is stopped. Assign a TNotifyEvent procedure to the property to perform actions needed when the timer is halted (or freed during execution). No actions are performed for the event notification when OnStopTimer is unassigned (contains Nil).

OnStopTimer is signalled from the KillTimer method when the timer class instance has been started and the property has been assigned.

Use the OnStartTimer event handler to perform actions needed when the timer class instance is started.

Use the OnTimer event handler to perform actions needed when the Interval for the timer has elapsed.