Results 1 to 5 of 5

Thread: Annoying SetTimer

  1. #1

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402

    Question

    Hello.

    How do you identify which timer called [/COLOR] a timersub ?



    I have 30 Timers called with SetTimer.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  2. #2

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402

    Thumbs up

    Thanks, Megatron. No matter it didnn't work! What is the third argument, though? The idevent?



    Silly of me to not test every argument.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  3. #3
    Megatron
    Guest
    Sorry, the 2nd argument is the WM_TIMER message. The 3rd argument is the timer ID (the ID you use to distinguish them)

  4. #4

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Thanks, Megatron.

    I got thrown off when the third argument has 30 values (I didn't realize that I called 30 timers). Then, the id is not 1,2,3,etc. because I forgot the hWnd.

    Anyway, I decided to sticking with one timer because 30 is too slow. Thanks anyway, I learned something new.



    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    hehe... Megatron does not get enough sleep

    Code:
    '//Put this code under a Form
    Option Explicit
    
    Private Sub Form_Load()
        '//Create 3 Timer
        SetTimer Me.hwnd, 0, 1000, AddressOf TimerProc
        SetTimer Me.hwnd, 1, 2000, AddressOf TimerProc
        SetTimer Me.hwnd, 2, 3000, AddressOf TimerProc
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        '//Kill all 3 timer
        KillTimer Me.hwnd, 0
        KillTimer Me.hwnd, 1
        KillTimer Me.hwnd, 2
    End Sub
    
    '//Put this code under a module
    Option Explicit
    Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As " & _
    	"Long) As Long
    Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    
    Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
        Select Case uElapse
        Case 0
            Form1.List1.AddItem "Timer 0 callback"
        Case 1
            Form1.List1.AddItem "Timer 1 callback"
        Case 2
            Form1.List1.AddItem "Timer 2 callback"
        End Select
    End Sub
    
    
    'Code improved by vBulletin Tool (Save as...)

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