本文整理自网络,侵删。
用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中destroy, free, freeandnil, release用法和区别
Delphi getprocessidentity 获取当前登录状态的管理员
Delphi 清除ie缓存 internet临时文件 cookie 历史记录 表单记录 上网密码
Delphi kbmmw sampleservice/sampleclient方式传输数据集
更多相关阅读请进入《Delphi》频道 >>