Link to home
Start Free TrialLog in
Avatar of Manuel Lopez-Michelone
Manuel Lopez-MicheloneFlag for Mexico

asked on

simple chronometer component

Hi guys,

I am looking for a simple chronometer component thats count from N seconds to zero. I found some components on the net but no one that runs backwards. Can anybody write a simple chronometer component. Minimal functionality: stop, pause, reset, running backward or forward...

thanks in advance...
Manuel Lopez (lopem)
Avatar of CrazyOne
CrazyOne
Flag of United States of America image

I am not sure overall what you are asking but for simple backwards couting using a set time I do this whay.

Lets say we want to count seconds and my statrting point is 10 and I want to count it down to 0. What I do is to setup a Timer (disabled) component with an interval of 1000 miliseconds. Now I declare a variable global to my unit and call it maybe iCountDown. Now I set the variable to

iCountDown := 10;

Now I enable the timer and on each cycle I Dec(iCountDown) until it hits 0.

Keep in mind this is a simple approach and not entirely precise in time measurement.

Something like this

var
  iCountDown: Integer;

procedure TForm1.Timer1Timer(Sender: TObject);
begin

  Dec(iCountDown);
  Label1.Caption := IntToStr(iCountDown);
  if iCountDown <= 0 then Timer1.Enabled := False;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  iCountDown := 10;
  Label1.Caption := IntToStr(iCountDown);
  Timer1.Enabled := True;

end;


The Crazy One
Avatar of wimmeyvaert
wimmeyvaert

I once wrote a little component which counts backwards.
This component had 1 event, OnCountFinished that was triggered the moment the counter reaches 0.

Maybe I can adapt it a little so that I can transform it into a chronometer.

Give me your email address and I'll send you this component if it is ready (Could take a while, because I'm pretty busy right now).

Best regards,
The Mayor.
Avatar of Manuel Lopez-Michelone

ASKER

morsa@la-morsa.com

I would really appreciate your effort... I will add 50 more points...

thanks in advance!

best regards
Manuel Lopez (lopem)
An extra 50 points ??

I start coding right away now ;-)
ASKER CERTIFIED SOLUTION
Avatar of wimmeyvaert
wimmeyvaert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks buddy...

I will check it tonight... In the meantime thanks again in advance.

best regards
manuel lopez (lopem)