VB 中运用 TimeSetEvent 代替 Timer 控件

窗体代码:

Option Explicit
Private Declare Function timeKillEvent Lib "winmm.dll" ( ByVal uID As Long ) As Long
Private Declare Function
timeSetEvent Lib "winmm.dll" ( ByVal uDelay As Long , ByVal uResolution As Long , ByVal lpFunction As Long , ByVal dwUser As Long , ByVal uFlags As Long ) As Long
Dim
p As Long
Private Const
TIME_周期 As Long = 1
Private Const TIME_一次性 As Long = 0

Private Sub Form_DblClick()
timeKillEvent p
p =
0
End Sub

Private Sub
Form_Load()
p = timeSetEvent(
300000 , 10 , AddressOf TimeProc, 1 , TIME_一次性)
Debug.Print timeGetTime
End Sub

Private Sub
Form_QueryUnload(Cancel As Integer , UnloadMode As Integer )
If p Then timeKillEvent p: p = 0 : Cancel = True : Timer1.Enabled = True
End Sub

Private Sub
Timer1_Timer()
Timer1.Enabled =
False
Unload Me
End Sub
[/font]



模块代码:

Option Explicit
Public Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub
TimeProc( ByVal uID As Long , ByVal uMsg As Long , ByVal dwUser As Long , ByVal dw1 As Long , ByVal dw2 As Long )
Debug.Print timeGetTime
End Sub

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值