Results 1 to 5 of 5

Thread: How to create and use a timer with API calls?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Question

    What is the procedure for creating and using timers?
    I don't want to use the control. I want to do it all by using the api.
    Which way is more efficient on resources and the like?
    BW

  2. #2
    Guest
    The SetTimer api function may be what your looking for .

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Cool Thanks a lot!!

    Thats exactly what i was after.
    Cheers for that. All go now.
    BW

  4. #4
    Guest
    I find that example too complex. Here is a more simple one.

    Code for a Module
    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)
    
    Public Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
        MsgBox "Timer message"
    End Sub
    
    Public Sub StartTimer(ByVal lInterval)
        SetTimer Form1.hWnd, 1000, lInterval, AddressOf TimerProc
    End Sub
    
    Public Sub StopTimer()
        KillTimer Form1.hWnd, 1000
    End Sub
    Code for a Form.
    Code:
    Private Sub Form_Load()
        StartTimer 1000
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        StopTimer
    End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Thumbs up Cheers Megatron

    Thats pretty much what i got the other example down to.. Cept for some user definable variables for the time length.
    Is it any more efficient to use the API over the timer control? Personally i like to use API over controls, then i know whats going on, well sorta. hehehe
    BW

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