找回密码
 加入
搜索
查看: 4881|回复: 3

[AU3基础] 回调函数的参数如何设置

[复制链接]
发表于 2013-6-14 20:04:49 | 显示全部楼层 |阅读模式
贴上定时器程序片段:
大侠们帮我讲解下,$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword");创建自定义函数Timer的回调,API定时器函数SetTimer需要
为什么这里要设置4个回调参数,每个参数的作用是什么,实在搞不定,我还发现最后一个参数"dword"可以删除掉,程序也能运行.
还有在Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)里, $idEvent可以获取定时器ID,这是如何获取的,搞不懂.

$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword");创建自定义函数Timer的回调,API定时器函数SetTimer需要
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer));1000毫秒执行一次
$Timer2DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 200, "ptr", DllCallbackGetPtr($Timer));200毫秒执行一次
$Timer3DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 2000, "ptr", DllCallbackGetPtr($Timer));2000毫秒执行一次

Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
Switch $idEvent;根据定时器ID来进行操作
        Case $TimerDLL[0]
                GUICtrlSetData($Label1, @HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC);更新时间
        Case $Timer2DLL[0]
                $t2 += 1
                GUICtrlSetData($Label2, $t2);更新+1
        Case $Timer3DLL[0]
                $t3 *= 2
                GUICtrlSetData($Label3, $t3);更新2的自乘
EndSwitch
EndFunc
发表于 2013-6-14 21:16:40 | 显示全部楼层
好复杂的东东,帮你顶下
发表于 2013-6-15 01:33:22 | 显示全部楼层
回复 1# tts780679
查看该回调函数的原型:
http://msdn.microsoft.com/en-us/library/ms644907(v=vs.85).aspx
第1个参数: 接收并处理计时器消息的窗口的句柄.
第2个参数: 计时器产生的消息的代号
第3个参数: 计时器的ID
第4个参数: 系统启动后所经历的时间. 以毫秒计算.

如果你看了这些没有什么体会,那建议你先弄明白什么是回调函数及其用处?

最后提醒你: 连发两贴,都是同一问题. 这样做很不好.
 楼主| 发表于 2013-6-15 18:26:35 | 显示全部楼层
谢谢回答,谢谢提醒,下次改正.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 01:21 , Processed in 0.087602 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表