Solved

CounDown timer

Posted on 2004-04-21
17
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

623 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