procedure Delay(msecs:integer); procedure TForm1.Delay(msecs:integer); var Tick: DWord; Event: THandle; begin Event := CreateEvent(nil, False, False, nil); try Tick := GetTickcount + DWord(msecs);
while (msecs > 0) and (MsgWaitForMultipleObjects(1, Event, False, msecs, QS_ALLINPUT) <> WAIT_TIMEOUT) do begin Application.ProcessMessages; msecs := Tick - GetTickcount; end;finally CloseHandle(Event);
end;
end;
DELPHI 中的Delay函数,利用GetTickCount和Application.ProcessMessages构建
原文:http://www.cnblogs.com/zhangzhifeng/p/5230035.html