Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2006, 12:26 AM
imijabar imijabar is offline
Senior Member
 
Join Date: May 2006
Posts: 182
Default Stopwatch timer

I want to show timer in form like stopwatch, but I couldn't show a millisecond while running, my code like below.....

========================================
procedure TForm1.SetRunning(Value: Boolean);
begin
if FRunning <> Value then
begin
FRunning := Value;
StartTime := ElapsedTime;
if Value then Reset := False;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var oLines : TStringlist;
begin
if Reset then ElapsedTime := Now else ElapsedTime := Now - StartTime;
if Running then
label1.Caption := FormatDateTime('hh:mm:ss.zz', ElapsedTime);

end;

procedure TForm1.Label1Click(Sender: TObject);
begin
running:=true;
end;

end.
=====================================
The format time I need is like this : 00:00:00.00 (hours,minutes,seconds,miliseconds)

there is something wrong with my code, cause the miliseconds not running like I need after I click label1(Tlabel) ?

I'm new in programming and my english not good, so forgive me for that.
help is better, do you agree?
Reply With Quote
  #2  
Old 08-09-2006, 12:32 AM
davidj davidj is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,900
Default RE: Stopwatch timer

Here is the complete code of a simple stop watch program.

[link]http://code.filehungry.com/go.php?url=373536343e37343033613b66326637303632373 03531326537313231363a32323735363b3e31353736353f633 26537303632376030653734373033303365363233363334&ref=267[/link]
Reply With Quote
  #3  
Old 08-09-2006, 12:50 AM
davidj davidj is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,900
Default RE: Stopwatch timer

Sorry, that zip seems to be corrupt.
Reply With Quote
  #4  
Old 08-09-2006, 01:35 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 6,700
Default RE: Stopwatch timer

Refresh the label after you set the Caption...
Code:
if Running then
begin
  Label1.Caption := TimeToStr(ElapsedTime);
  Label1.Refresh;
end;
But perhaps the interval of your timer is to short...

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1
Reply With Quote
  #5  
Old 08-10-2006, 11:33 PM
imijabar imijabar is offline
Senior Member
 
Join Date: May 2006
Posts: 182
Default RE: Stopwatch timer

yup it is corrupt,

I'm new in programming and my english not good, so forgive me for that.
help is better, do you agree?
Reply With Quote
  #6  
Old 08-10-2006, 11:40 PM
imijabar imijabar is offline
Senior Member
 
Join Date: May 2006
Posts: 182
Default RE: Stopwatch timer

did u have a code sample for create stopwatch with format "hh:nn:ss.ms" (hour:minute:second:millisecond)

I'm new in programming and my english not good, so forgive me for that.
help is better, do you agree?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:44 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.