| |
| Creating a delay without a timer. |
 |
How do I create a delay without using a TTimer component, and without locking up the system?
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 TForm .Button Click(Sender: TObject);
begin
ShowMessage('Start Test');
Delay(2000);
ShowMessage('End Test');
end;
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|