Bei mir funktioniert das so:
Delphi-Quellcode:
var
Form1: TForm1;
implementation
{$R *.dfm}
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
showmessage('Bitte warten ...');
delay(5000);
showmessage('Das Waren ca. 5 secs');
end;
end.