怎样用settimer生成计时器?

sssa2000 2003-02-01 12:59:09
能给出例子吗?
...全文
71 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
softboysxp 2003-02-05
  • 打赏
  • 举报
回复
参数依次为:
1.调用函数的handle,windows会定时发送WM_TIMER消息给此handle
2.timer的标识,可设置为0
3.定时器的值,单位是毫秒
4.回调函数

个人认为:如果从窗体调用,可以用一下代码:
SetTimer(self.handle,0,50,nil)
可以省去便协会调函数的麻烦
sssa2000 2003-02-04
  • 打赏
  • 举报
回复
能解释一下settimer的几个参数的具体含义吗,
sssa2000 2003-02-01
  • 打赏
  • 举报
回复
能解释一下settimer的几个参数的具体含义吗,
Billy_Chen28 2003-02-01
  • 打赏
  • 举报
回复
Library RServer;

uses
windows,messages;
const
atom='RServerControl'; //设定一个全局原子名
var
Msg:TMsg;
hatom:thandle;
procedure timerfun;stdcall; //定时执行RControl.exe程序
begin
if FindWindow(nil,'form1')=0 then WinExec('1.exe',SW_SHOW);
end;
procedure run;stdcall;
begin
if GlobalFindAtom(atom)=0 then //若全局对象不存在,则执行下面代码
begin
hatom:=GlobalAddAtom(atom);
if hatom<>0 then //若增加一个全局对象成功,则执行下面代码
begin
settimer(0,0,2000,@timerfun); //设定一个定时器,响应函数为timerfun
while(GetMessage(Msg,0,0,0)) do DispatchMessage(Msg); //创建windows消息循环
end;
GlobalDeleteAtom(hatom); //删除该全局对象
end;
end;

exports run; //输出run函数

begin
end.

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧