Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CounDown timer

Posted on 2004-04-21
17
Medium Priority
?
407 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 120 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

688 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