如何用API写的程序有Timer控件功能(20分)

  • 主题发起人 主题发起人 sunjunfeng3
  • 开始时间 开始时间
S

sunjunfeng3

Unregistered / Unconfirmed
GUEST, unregistred user!
在纯API里调用也行,我的程序调用不行总是出错,希望好的代码 <br>我的错误代码如下<br>procedure ThreadPro(X: Integer); stdcall;<br>var<br> &nbsp;timer1:TTimer1;<br> &nbsp;MsgStruct: TMsg;<br> &nbsp;hMutexObj: DWORD;<br>begin<br> &nbsp;hMutexObj := CreateMutex(nil, FALSE, DllMutex);<br> &nbsp;timer1:=ttimer.Create(nil);<br> &nbsp;timer1.OnTimer:=TimerExee;<br> &nbsp;timer1.Interval:=5000;<br> &nbsp;timer1.Enabled:=true;<br> // Register_MainForm;<br> &nbsp;//Create_MainForm;<br> &nbsp;while GetMessage(MsgStruct, 0, 0, 0) do<br> &nbsp;begin<br> &nbsp; &nbsp;case msgstruct.message of<br> &nbsp; &nbsp; &nbsp; &nbsp;wm_close: BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox(0,' wm_close退出','插入',1);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp; &nbsp; &nbsp;END;<br> &nbsp; &nbsp; &nbsp; &nbsp;wm_quit:begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox(0,' wm_quit退出','插入',1);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;wm_vscroll:BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox(0,'wm_vscroll 被滚动','插入',1);<br> &nbsp; &nbsp; &nbsp; &nbsp;END;<br><br><br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp; //TranslateMessage(MsgStruct);<br> &nbsp; &nbsp;//DispatchMessage(MsgStruct);<br> &nbsp;end;<br> &nbsp;//Unregister_MainForm;
 
为什么要用API写,有TIMER不用?
 
我就是在API里用TIMER对像不成功啊,主要是,办有办法做事件 处理程序<br>timer1.OnTimer:=TimerExee; 这句话报严重错误
 
晕死,你搜索一下多线程版里面的定时器的功能,还有看看delphi深度历险,里面对定时器专门的讲解,里面有专门使用api搞的定时器的,绝对满足你的要求!
 
呵呵,用TIMER控件程序要用FORM,太大了。。。写木马不能用FORM,只能用API写TIMER
 
timer1:=ttimer.Create(nil);<br> &nbsp;timer1.OnTimer:=TimerExee;<br> &nbsp;timer1.Interval:=5000;<br> &nbsp;timer1.Enabled:=true;<br>你的以上这几句实际上已经创建了一个timer对象.<br>timer1.OnTimer:=TimerExee;这一行之所以出错,<br>可能是timerexee这个过程没有定义.<br>你可以把这个过程定义一下:<br>procedure timerexee();<br>begin<br>//你的定时执行代码<br>end;
 
哎还是自己搞定了,弄了一个SETTIMER &nbsp;调用了API达到了同样的效果
 
[:)]祝贺,<br>不过我的方法应该也可以解决的!
 
TTimer 本来就是用 SetTimer / KillTimer API 做的嘛,它不过是封装好向你的窗口发个消息而已
 
后退
顶部