Solved

Countdown to 2000

Posted on 1999-01-09
6
233 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:borgo
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1355527
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1355528
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
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355529
Hi meikl, looks nice...  :-)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:borgo
ID: 1355530
Thank you Madshi.
But I find that the kretzschmar's answer is easier than yours.


0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355531
No prob...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 1355532
Hi Borgo,
you can the year2000 also place in a constant

const
  Y2000 = 36526; {the Value of 01/01/2000 00:00:00}

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

meikl
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now