本文整理自网络,侵删。
用delphi怎么实现延时功能?在delphi中有一个sleep()函数是用来暂停线程的,使用了它好像和死掉了似得,不好用,这么简单的延时动作用Timer控件有显得复杂了。
下面给大家分享一个真正好用的延时功能:
procedure delay(MSecs:LongInt);
var
FirstTickCount,Now:LongInt;
begin
FirstTickCount:=GetTickCount();
repeat
Application.ProcessMessages;
Now:=GetTickCount();
until (Now - FirstTickCount >=MSecs)or(Now<FirstTickCount);
end;
//调用
delay(1000);//延时一秒
出处:http://www.ppblog.cn/delay.html
相关阅读 >>
Delphi waitforsingleobject 响应窗体
Delphi searchrec.attr and fadirectory
更多相关阅读请进入《Delphi》频道 >>