首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

SetTimer 回调函数失败,该怎么处理

2012-01-10 
SetTimer 回调函数失败VB.NET codeOption Explicit OnModule WinTimerDeclare Function SetTimer Lib use

SetTimer 回调函数失败

VB.NET code
Option Explicit OnModule WinTimer    Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Callback) As Integer    Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long    Public lngTimerID  As Long    Delegate Sub Callback(ByVal hwnd As Integer, ByVal uMsg   As Integer, ByVal idEvent As Integer, ByVal dwTime As Integer)        Public Sub TimeProcCallback(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal idEvent As Integer, ByVal dwTime As Integer)   MessageBox.Show("ok")    End SubEnd Module'窗口内按钮单击事件调用Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.ClicklngTimerID = SetTimer(0, 0, times, AddressOf TimeProcCallback)End Sub


[解决办法]
VB.NET code
    Public WriteAccess As Long    Public Delegate Sub TimerEventHandler(ByVal uID As UInt32, ByVal uMsg As UInt32, ByRef dwUser As UInt32, ByVal dw1 As UInt32, ByVal dw2 As UInt32)    Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As UInt32, ByVal uResolution As UInt32, ByVal lpFunction As TimerEventHandler, ByRef dwUser As UInt32, ByVal uFlags As UInt32) As UInt32    Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As UInt32) As UInt32    Public mTimerCallback As TimerEventHandler 

热点排行