Schon mal an einen Timer gedacht?
Geht wunderbar:
Delphi-Quellcode:
procedure delay(msec:longint);
var
start,stop:longint;
begin
start := gettickcount;
repeat
stop := gettickcount;
application.processmessages;
until (stop - start ) >= msec;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to 60 do
begin
Application.ProcessMessages;
Label1.Caption := IntToStr(i);
Delay(1000);
end;
end;
Bzw. so wie du es willst:
Delphi-Quellcode:
procedure delay(msec:longint);
var
start,stop:longint;
begin
start := gettickcount;
repeat
stop := gettickcount;
application.processmessages;
until (stop - start ) >= msec;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, calc : Integer;
begin
calc := 61;
for i := 0
to 60
do
begin
Application.ProcessMessages;
Dec(calc);
Label1.Caption := IntToStr(calc);
Delay(1000);
end;
end;
Oder so:
Delphi-Quellcode:
procedure delay(msec:longint);
var
start,stop:longint;
begin
start := gettickcount;
repeat
stop := gettickcount;
application.processmessages;
until (stop - start ) >= msec;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
for i := 60 downto 0 do
begin
Application.ProcessMessages;
Label1.Caption := IntToStr(i);
Delay(1000);
end;
end;