Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Transfer time values (https://www.delphipraxis.net/152058-transfer-time-values.html)

sdean 9. Jun 2010 18:52

Delphi-Version: 2005

Transfer time values
 
Hi , i want to Transfer an Elapsed time from timer to an other time ;

i use the following code to calc the Elapsed Time :

Delphi-Quellcode:
procedure TForm1.Time1Timer(Sender: TObject);
var
    s: string;
    TotalTime: TDateTime;
    DLTimes: Double;
    Hh, Mh, sSec, MSs: Word;
begin
TotalTime:= Now-FStartTime;


  DecodeTime(TotalTime, hH, Mh, sSec, MSs);
  sSec := sSec + Mh * 60 + hH * 3600;
   DLTimes := sSec + MSs / 1000;
  s:=Format('%2d:%2d:%2d', [sSec div 3600, (sSec div 60) mod 60, sSec mod 60]);
FElapsedTime:=FormatDateTime('hh:nn:ss', StrToTime(s));
end
So what i want to do is : when i stop timer1 and start timer2 then
timer2 will continue incrementing the FElapsedTime value .

let me suppose this :

when i stopped timer1 the FElapsedTime value was : 00:50:00 ; then when i start Timer2 the FElapsedTime value will be 00:51:00 ....etc incrementing the FElapsedTime value .


thank you

idefix2 9. Jun 2010 20:18

AW: Transfer time values
 
When timer 1 is started, you save the start time:
Delphi-Quellcode:
Timer1starttime := now;
When timer 1 is stopped:

Delphi-Quellcode:
elapsedtime1 := now - timer1starttime;
When timer 2 is started, again you save the starttime

Delphi-Quellcode:
timer2starttime := now;
When time 2 stops, elapsed time is:

Delphi-Quellcode:
elapsedtime2 := now-timer2starttime;
Total elapsed time is

Delphi-Quellcode:
totalelapsedtime := elapsedtime1 + elapsedtime2;


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz