Posted by Jenny on May 25, 2005
In Reply to: How can do timing program? posted by zmo
on May 15, 2005
If you want to stop the program after a certain time, it's best to use a TTimer component, that checks if the time has elapsed, for example every second.
Drop a Timer component on the main form, say Timer1, set its property Enabled to False, and set Interval to 1000. Create an OnTimer event:
procedure TForm1.Timer1Timer(Sender: TObject); begin if Time >= TimeToStop then Close; end;
Drop a TEdit component on the form, to enter the delay time (waiting time) in seconds. Set its property Text to 1.
Drop a Button on the form, and make an OnClick event handler like this:
procedure TForm1.Button1Click(Sender: TObject); begin TimeToStop := Time + StrToInt(Edit1.Text)/(3600*24); Timer1.Enabled := True; end;
Finally, add a global variable:
Related Articles and Replies