Timer. |
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, JvExControls,
JvNavigationPane, Vcl.StdCtrls, Vcl.ComCtrls;
type
TForm1 = class(TForm)
JvNavPanelHeader1: TJvNavPanelHeader;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
Lap: word;
public
{ Public declarations }
end;
var
Form1: TForm1;
SYS_CREATE: TDateTime;
RUN_TIME: TDateTime;
implementation
{$R *.dfm}
uses System.DateUtils;
function SecondToTime(const Seconds: Cardinal): Double;
var
ms, ss, mm, hh, dd: Cardinal;
begin
dd := Seconds div SecsPerDay;
hh := (Seconds mod SecsPerDay) div SecsPerHour;
mm := ((Seconds mod SecsPerDay) mod SecsPerHour) div SecsPerMin;
ss := ((Seconds mod SecsPerDay) mod SecsPerHour) mod SecsPerMin;
ms := 0;
Result := dd + EncodeTime(hh, mm, ss, ms);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SYS_CREATE := Now;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
case SElf.WindowState of
wsMaximized:
JvNavPanelHeader1.Font.Size := 128;
wsMinimized, wsNormal:
JvNavPanelHeader1.Font.Size := 48;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
RUN_TIME := SecondToTime(SecondsBetween(SYS_CREATE, Now));
JvNavPanelHeader1.Caption := formatdatetime('hh:mm:ss', RUN_TIME);
end;
end.
Comments
Post a Comment