SimpleTimer is a timer class. It is more lightweight than a TTimer component, as it doesn't require a handle, and since it's derived from TObject there's less overhead. This makes it ideal for developers who need a timer in their own components or applications, but want to keep the resource usage minimal.
Owner | property Owner: TComponent; The owner of the timer. |
Read-only |
Active | property Active: Boolean; Whether the timer is running. |
Read-only |
Create | type TSimpleTimerCallBackProc = procedure(AOwner: TComponent); stdcall; constructor (AOwner: TComponent; CallBackProc: TSimpleTimerCallBackProc); Creates a new TSimpleTimer instance. You need to declare a procedure of type TSimpleTimerCallBackProc which will be called continuously at the interval you specify in the Start method. NOTE: Be sure to declare the stdcall directive, as is normal practice with callback methods. NOTE: The callback method cannot be part of any class. It must be a simple method. |
Returns new TSimpleTimer object |
Start | function Start(MilliSecs: Cardinal): Boolean; Starts the timer, using the specified interval in millisecs. If the timer is already running it will be stopped, then restarted with the new interval. NOTE: If the method returns false it means the system has run out of timer resources. That's bad. |
Returns true or false |
Stop | function Stop: Boolean; Stops the timer. |
Returns true or false |
procedure TForm1.FormCreate(Sender: TObject); begin SimpleTimer1 := TSimpleTimer.Create(Self, @TimerProc1); SimpleTimer1.Start(1000); end;
procedure TimerProc1(AOwner: TComponent); stdcall; begin with (AOwner as TForm1) do ListBox1.Items.Add('SimpleTimer1 fired'); end;
Get the latest version from http://www3.ewebcity.com/troels/delphi.asp.
Troels Jakobsen
delphiuser@get2net.dk