Реализация функции Delay 2



Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

procedure Delay(msecs: Longint);
var
targettime: Longint;
Msg: TMsg;
begin
targettime := GetTickCount + msecs;
while targettime > GetTickCount do
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
If Msg.message = WM_QUIT Then
begin
PostQuitMessage(msg.wparam);
Break;
end;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
{
Note:
The elapsed time is stored as a DWORD value.
Therefore, the time will wrap around to zero if the system is
run continuously for 49.7 days.
}

Далее: Реализация функции Delay 3 »»