unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
// drei Buttons auf dem Formular plazieren und benennen
Go: TButton;
Stop: TButton;
Reset: TButton;
Label1: TLabel;
procedure GoClick(Sender: TObject);
procedure StopClick(Sender: TObject);
procedure ResetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;
TMein = class(TThread)
private
diff: longword;
protected
procedure Execute; override;
procedure doit;
end;
const lauf: boolean = false;
var Form1: TForm1;
zeit: longword;
zsc, sec, min, std, merk: word;
implementation
{$R *.DFM}
procedure anzeige;
var st, mi, se, zs: string;
begin
st := inttostr(std);
mi := inttostr(min); if min < 10 then mi := '0' + mi;
se := inttostr(sec); if sec < 10 then se := '0' + se;
zs := inttostr(zsc);
form1.label1.caption := st + ':' + mi + ':' + se + ',' + zs;
end;
procedure TMein.doit;
begin
diff := gettickcount - zeit;
std := diff div 3600000; diff := diff - std * 3600000;
min := diff div 60000; diff := diff - min * 60000;
sec := diff div 1000; diff := diff - sec * 1000;
zsc := diff div 100;
if merk <> zsc then begin // Anzeige nur bei Änderung
merk := zsc;
anzeige;
end;
end;
procedure TMein.Execute;
begin
repeat
if lauf then synchronize(doit);
until false;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TMein.create(false);
resetclick(form1);
end;
procedure TForm1.GoClick(Sender: TObject);
begin
go.enabled := false;
stop.enabled := true;
reset.enabled := false;
zeit := gettickcount;
lauf := true;
end;
procedure TForm1.StopClick(Sender: TObject);
begin
lauf := false;
stop.enabled := false;
reset.enabled := true;
end;
procedure TForm1.ResetClick(Sender: TObject);
begin
zsc := 0;
sec := 0;
min := 0;
std := 0;
merk := 0;
go.enabled := true;
stop.enabled := false;
reset.enabled := false;
anzeige;
end;
end.