Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting a TTimer component

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I am writing a small application that allows the user to run a process at intervals of an indicated number of minutes. Ideally I want the user to set a time for starting the running of these intervals. Is there a way in which I can start the TTimer (enabling it) at a given time (as indicated by the user). Will I need to use a second TTimer for this (or am I missing the obvious) ??
Steve
 
Hi Steven,

What I would do is make an "Apply" button and make
the timer run then. You can do that by:

Timer1.enabled := true;

On the minutes or seconds part whichever you choose
(for which I recommend a TSpinEdit) just multiply it in
the program.

So it would look kinda like this. This example works with
1 counting as 1 minute.

procedure TForm1.ApplyButton(Sender: TObject);
var minutes: integer;
begin
minutes := SpinEdit1.Value * 60000;
Timer1.Interval := minutes;
Timer1.Enabled := True;
end;

procedure TForm1.Timer1OnTimer(Sender: TObject);
var minutes: integer;
begin
minutes := Timer1.Interval / 60000;
ShowMessage('This message shows every '+ IntToStr(minutes) +' !!!');
end;

So you place the procedure that you want to execute at every
so many minutes at the place where i put the messagebox.

I hope this helps,

BobbaFet




Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top