Link to home
Start Free TrialLog in
Avatar of borgo
borgo

asked on

Countdown to 2000

I'm looking to code a 2000 countdown timer.
Do you have any design advice ?
Have I to use label component and thread ? Or what else ?
I use TDate  component. Then I calculate the days to the 1/1/2000 How can I print the TDate value as dd/mm/yy hh:mm:ss ? I try with DateToStr but it's a value like dd/mm/yy.
Avatar of Madshi
Madshi

Hmmm. I think it could be a small window with "formStyle:=fsStayOnTop" and either with a toolWindows borderStyle or with no border at all.
You could use a label component. But I would suggest a simple TTimer object to do the work. Normally you don't need a thread for this.
Then you could use the function DateTimeToSystemTime, which converts TDateTime to TSystemTime.
type
  TSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;
Then you can format the string yourself.

More questions? Please ask...  :-)

Regards, Madshi.
Avatar of kretzschmar
hi borgo,

in addition to madshi a year 2000 Countdown

procedure TForm1.Timer1Timer(Sender: TObject);
Var
  R : Real;
begin
  r := StrToDateTime('01/01/2000 00:00:00') - Now;
  Label1.caption := FloatToStr(Int(r)) + ' Days ' +TimeToStr(r);
end;

meikl
Hi meikl, looks nice...  :-)
Avatar of borgo

ASKER

Thank you Madshi.
But I find that the kretzschmar's answer is easier than yours.


No prob...
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

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