Показать сообщение отдельно
  #2  
Старый 01.11.2007, 01:46
Zuzlan Zuzlan вне форума
Прохожий
 
Регистрация: 01.11.2007
Сообщения: 8
Репутация: 10
По умолчанию

Получил ответ на другом форуме:

Автор 7inner

Итак, открываем какой нибуть фак:
1)

procedure Delay(Milliseconds: Integer);
{by Hagen Reddmann}
var
Tick: DWord;
Event: THandle;
begin
Event := CreateEvent(nil, False, False, nil);
try
Tick := GetTickCount + DWord(Milliseconds);
while (Milliseconds > 0) and
(MsgWaitForMultipleObjects(1, Event, False, Milliseconds, QS_ALLINPUT) <> WAIT_TIMEOUT) do
begin
Application.ProcessMessages;
Milliseconds := Tick - GetTickcount;
end;
finally
CloseHandle(Event);
end;
end;


2)

procedure PauseFunc(delay: DWORD);
var
lTicks: DWORD;
begin
lTicks := GetTickCount + delay;
repeat
Sleep(100);
Application.ProcessMessages;
until (lTicks <= GetTickCount) or Application.Terminated;
end;


3)SleepEx
4)

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.
}



На самом деле все реализации демонструют то, что лучше чем Sleep/SleepEx/Application.processmessages нет
Ответить с цитированием