procedure Delay(msecs: integer); //延时 毫秒 var Tick: DWord; Event: THandle; begin Event := CreateEvent(nil, False, False, nil); try 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; except on e: Exception do end; finally CloseHandle(Event); end; end;