Главная страница | назад





Article #15830: Creating a delay without a timer.

 Question and Answer Database
FAQ830D.txt Creating a delay without a timer.
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I create a delay without using a TTimer component,
and without locking up the system?
Answer:
Here is an example of using a loop that checks the time and
calls Application.ProcessMessages to allow Windows messages
to be processed during the loops execution.
procedure Delay(ms : longint);
var
TheTime : LongInt;
begin
TheTime := GetTickCount + ms;
while GetTickCount < TheTime do
Application.ProcessMessages;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('Start Test');
Delay(2000);
ShowMessage('End Test');
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99