Solved

CounDown timer

Posted on 2004-04-21
17
398 Views
Last Modified: 2010-04-05
i want to make Count down Timer Witch Begin From 01:00:00  hour for example and count down to 00:00:00 How to represent that in digital clock ?
0
Comment
Question by:Prof_MAM
  • 5
  • 5
  • 3
  • +2
17 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 30 total points
ID: 10886074
Place Label and 2 buttons on a form

  private
    { Private declarations }
    StartTime: TDateTime;
    StartValue: TDateTime;


procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1.Font.Name := 'Arial';
  Label1.Font.Size := 30;
  Label1.Font.Style := [fsBold];
  Button1.Caption := 'Set';
  Button2.Caption := 'Start';
  SetTime;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetTime;
end;

procedure TForm1.SetTime;
begin
  Timer1.Enabled := False;
  StartValue := 3600./SecsPerDay; // 1 hour
  Label1.Caption := FormatDateTime('hh:nn:ss',StartValue);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Timer1.Enabled := True;
  StartTime := Now;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  str: string;
  t: TDateTime;
begin
  t := StartValue + StartTime - Now;
  if t < 0 then
    t := 0;
  str := FormatDateTime('hh:nn:ss',t);
  if str <> Label1.Caption then
    Label1.Caption := str;
end;
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10886179

  one label and one timer

  {----------------------------------------------------------}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    UpTime    : TDateTime;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  tmp : TSystemTime;
begin
  with tmp do
    begin
      // the date is not important
      wYear          := 2004;
      wMonth         := 4;
      wDayOfWeek     := 3;
      wDay           := 22;
      // initialize the time
      wHour          := 1;
      wMinute        := 0;
      wSecond        := 1;
      wMilliseconds  := 0;
    end;
  UpTime := SystemTimeToDateTime(tmp);
  UpTime := Now + Uptime;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := FormatDateTime('hh:nn:ss', UpTime - Now);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 10896278
For 200 extra points I can send you my own component what do exactly what you need. I use it ( in component ) to shut down the system after a specified time, but you can change this action to adapt for your needs.

Until then I can send a sample demo.
0
 

Author Comment

by:Prof_MAM
ID: 10897060
for moukle And Ivanov_G Your Solution Are excelent but I don't want to use Labels Ineed Somthing more beatiful (For Look And fell).
For  ginsonic I am really have null Points so I can't increas the points because Ihaven't
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10897077

  You can use some LED component. Take a look here :

  http://www.torry.net/pages.php?id=120

  (this is in case you want to make it look like electronic clock)
0
 
LVL 17

Expert Comment

by:mokule
ID: 10897094
I'm using images drawn by myself for this purpose.
They are corresponding with scoreboards I'm using.
Best draw it yourself, it's only ten digits :) and some background image.
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 10900416
Don't shout me for try :) I need points to have full access to this portal ( 3000 points/month ).

Give me your address to send the file.
0
 

Expert Comment

by:sraab2004
ID: 10903428
for ginsonic
sorry for being late this is my email  
prof_mam1@hotmail.com
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Expert Comment

by:sraab2004
ID: 10903455
for  Ivanov_G : iam using delphi 7 and torry comonent work with d1 -d2 ...d5
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10903814

   I installed Advanced Led v.1.0 on Delphi 7 without problems. I was unable to install in on D8, but on D7 it works fine.... Try it...
0
 

Author Comment

by:Prof_MAM
ID: 10907273
I installed the component successfully how to use it?
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10908181

   Set the properties and handle each time tick - let's say 1000 ms - 1 seconds...
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 10910725
Read your mail.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10915954

   Sorry, my mistake. I gave you wrong component to install. Try TDynaLED v.1.0.
   It behaves like clock and have caption property, so in my code above you have to change this :

  procedure TForm1.Timer1Timer(Sender: TObject);
  begin
    DynaLED1.Caption := FormatDateTime('hh:nn:ss', UpTime - Now);
  end;
0
 

Author Comment

by:Prof_MAM
ID: 10921626
there is missing file in your packge ginsonic DsgnIntf.Dcu
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 10928676
Isn't messing. I think that you use D6 or up.
DsgnIntf is now DesignIntf
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 10928684
For messing read missing . Ups!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

15 Experts available now in Live!

Get 1:1 Help Now