Registriert seit: 30. Nov 2005
Ort: München
5.771 Beiträge
Delphi 10.4 Sydney
|
Re: Timer (Amateuerfrage)
16. Apr 2007, 20:04
Delphi-Quellcode:
procedure Delay(Milliseconds: Integer);
var
Tick: DWord;
Event: THandle;
begin
Event := CreateEvent(nil, False, False, nil);
try
Tick := GetTickCount + DWord(Milliseconds);
while (Milliseconds > 0) and
(MsgWaitForMultipleObjects(1, Event, False, Milliseconds, QS_ALLINPUT) <> WAIT_TIMEOUT) do
begin
Application.ProcessMessages;
if Application.Terminated then Exit;
Milliseconds := Tick - GetTickcount;
end;
finally
CloseHandle(Event);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
max:=100;
i:=1;
ProgressBar1.Max:=max;
while i < max do
begin
IdIcmpClient1.Host := Form1.Edit1.Text;
IdIcmpClient1.Ping();
If IdIcmpClient1.ReplyStatus.BytesReceived > 0 Then
ListBox1.Items.Add(IntToStr(i) + ' ' + IdIcmpClient1.Host+' erreichbar '+ IntToStr(IdIcmpClient1.ReplyStatus.BytesReceived))
else
ListBox1.Items.Add(IntToStr(i) + ' ' + IdIcmpClient1.Host+' nicht erreichbar');
i:=i+1;
delay(StrToInt(Edit2.Text)); // <----
ProgressBar1.Position:=i;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:=False;
Form1.Refresh;
Application.ProcessMessages;
Timer1.Enabled:=True;
end;
Grüße
Klaus
Klaus
|
|
Zitat
|