SimpleTimer is a timer class. It has the same timer resolution as TTimer, but it is more lightweight because it's derived from TObject in stead of TComponent. Furthermore, the same handle is shared between multiple instances of SimpleTimer. 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.brinkster.com/troels/delphi.asp.
Troels Jakobsen
delphiuser@get2net.dk