Results 1 to 4 of 4

Thread: Is SetTimer API usable for Win95

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    India
    Posts
    22

    Is SetTimer API usable for Win95

    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
    I know I wont get much sleep tonight but that does'nt stop me from going to bed.

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    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 ). The VB TimerProc procedure looks identical to the one in MSDN.
    VB Code:
    1. 'in a module
    2. Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerProc As Long) As Long
    3. Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    4.  
    5. Public Sub TimerProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal nIDEvent As Long, ByVal dwTicks As Long)
    6.    'your stuff here for the timer procedure
    7. End Sub
    8.  
    9. 'set a 1 second timer in Form1 with an ID of 1
    10. SetTimer Form1.hWnd, 1, 1000, AddressOf TimerProc
    11.  
    12. 'stop the timer
    13. KillTimer Form1.hWnd, 1
    14.  
    15.  
    16. 'set a 1 second timer that is not associated with any window
    17. Dim hTimer As Long
    18. hTimer = SetTimer(0, 0, 1000, AddressOf TimerProc)
    19.  
    20. 'stop the timer
    21. KillTimer 0, hTimer
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    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.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width