Author | Message | Time |
---|---|---|
Networks | Can anyone provide some example code of how to create a timer (not the control)? And some explaination of key statements and how they are used. Thank you in advance. | August 28, 2004, 6:40 PM |
Flame | [code] Declare Function SetTimer Lib "user32.dll" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Declare Function KillTimer Lib "user32.dll" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long [/code] -hWnd = Window handle to use. -nIDEvent = Event index. Basically if you want to set multiple timers, you're going to want to use different IDEvent numbers, if you want to kill a timer, you need to use the IDEvent in which it was originally set with. -uElapse = Time elapsed in MS. -lpTimerFunc = Address of the routine to call once the timer has expired. [code]Public Sub Main() SetTimer frmMain.hWnd, 1, 100, AddressOf MySub End Sub Public Sub MySub Debug.Print "Hi!" KillTimer frmMain.hWnd, 1 End Sub [/code] An additional note, you can also use SetTimer to change the interval on an existing timer. | August 29, 2004, 11:00 PM |
Eli_1 | I may be wrong, but don't you need to use a timerproc as your callback function? [code] Public Sub MySub(ByVal hWnd as Long, ByVal uMsg as Long, ByVal idEvent as Long, ByVal dwTime as Long) Select Case idEvent Case MYTIMER_ONE: DoStuff1() Case MYTIMER_TWO: DoStuff2() Case MYTIMER_THREE: DoStuff3() End Select End Sub [/code] | August 30, 2004, 12:29 AM |
Networks | yea.. I figured it out after the post but thank you guys anyway. | August 31, 2004, 10:48 PM |