Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Diagnostics, StdCtrls;
- type
- TfrmSW = class(TForm)
- lblSW: TLabel;
- btnStartStop: TButton;
- btnReset: TButton;
- procedure btnStartStopClick(Sender: TObject);
- procedure btnResetClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmSW: TfrmSW;
- sw: TStopWatch;
- SWRunning: boolean;
- implementation
- {$R *.dfm}
- procedure TfrmSW.btnResetClick(Sender: TObject);
- begin
- if not SWRunning then lblSW.Caption := '00:00:00.000';
- end;
- procedure TfrmSW.btnStartStopClick(Sender: TObject);
- begin
- SWRunning := not SWRunning;
- if SWRunning then sw := TStopwatch.StartNew;
- while(SWRunning) do
- begin
- lblSW.Caption := FormatDateTime('hh:nn:ss.zzz',sw.ElapsedMilliseconds/MSecsPerDay);
- // Handle any external events
- Application.ProcessMessages;
- end;
- // Set form DoubleBuffered property to True to prevent flickering
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment