Delphi 延迟函数 比sleep 要好的多   
               添加时间:2013-7-2 点击量: 
 
              转自:http://www.cnblogs.com/Bung/archive/2011/05/17/2048867.html
  //延迟函数:办法一
  procedure 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; 
  //延迟函数:办法二
  procedure Delay(dwMilliseconds:DWORD);//Longint
  var
  iStart,iStop:DWORD;
  begin
  iStart :=&#160;&#160; GetTickCount;
  repeat
  iStop&#160; :=&#160;&#160; GetTickCount;
  Application.ProcessMessages;
  until (iStop&#160; -&#160; iStart) >= dwMilliseconds;
  end; 
无论对感情还是对生活,“只要甜不要苦”都是任性而孩子气的,因为我们也不完美,我们也会伤害人。正因为我们都不完美,也因为生活从不是事事如意,所以对这些“瑕疵”的收纳才让我们对生活、对他人的爱变得日益真实而具体。—— 汪冰《世界再亏欠你,也要敢于拥抱幸福》
                     
                  
     
  
 
    
    
转自:http://www.cnblogs.com/Bung/archive/2011/05/17/2048867.html
//延迟函数:办法一
procedure 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; 
//延迟函数:办法二
procedure Delay(dwMilliseconds:DWORD);//Longint
var
iStart,iStop:DWORD;
begin
iStart :=&#160;&#160; GetTickCount;
repeat
iStop&#160; :=&#160;&#160; GetTickCount;
Application.ProcessMessages;
until (iStop&#160; -&#160; iStart) >= dwMilliseconds;
end; 




