Documentation for SetTimer says it requires Win 95 or later but
documentation for its callback function TimerProc says that Win 98 or later is required.
I am confused.Plz Help:confused:
Printable View
Documentation for SetTimer says it requires Win 95 or later but
documentation for its callback function TimerProc says that Win 98 or later is required.
I am confused.Plz Help:confused:
I'm not sure why it says win98 in the info about the TimerProc thing in MSDN, but SetTimer works fine inside win95. I've used it on my laptop many times with no problems (except for those instances where I forget to turn them off, and then end the prog :D ). The VB TimerProc procedure looks identical to the one in MSDN.
VB Code:
'in a module Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerProc As Long) As Long Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Public Sub TimerProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal nIDEvent As Long, ByVal dwTicks As Long) 'your stuff here for the timer procedure End Sub 'set a 1 second timer in Form1 with an ID of 1 SetTimer Form1.hWnd, 1, 1000, AddressOf TimerProc 'stop the timer KillTimer Form1.hWnd, 1 'set a 1 second timer that is not associated with any window Dim hTimer As Long hTimer = SetTimer(0, 0, 1000, AddressOf TimerProc) 'stop the timer KillTimer 0, hTimer
It could be that in order to use a callback timer you need 98. However, a timer that sends a message to your window works on 95.
The callback still works on win95 though. If a callback doesn't work though, there's something else going on under the hood since it doesn't give any errors and otherwise works fine.