Mega Code Archive

 
Categories / Delphi / Examples
 

Delay

Subject: Delay This is an equivalent to the Delay procedure in Borland Pascal. You may find it of interest. It is not mine. It was given to me by someone else who did not cite the source. Hope it helps your important WWW page. Take care. procedure TForm1.Delay(msecs:integer); var FirstTickCount:longint; begin FirstTickCount:=GetTickCount; repeat Application.ProcessMessages; {allowing access to other controls, etc.} until ((GetTickCount-FirstTickCount) >= Longint(msecs)); end; ***************************************************************** a DIY Delay procedure... IF you need more scope ie a longer delay period, then add extra parameters to the procedure ie hours minutes seconds... procedure TRandForm.Delay(milliSeconds: Word); {pause execution for a given number of milliseconds...} var timeOut: TDateTime; begin {EncodeTime encodes the given hour, minute, second, and millisecond into a TDateTime value...} timeOut := Now + EncodeTime(0, 0, 0, milliseconds); {wait until the timeOut time...} while (Now < timeOut) do begin Application.ProcessMessages; end; end;