Link to home
Start Free TrialLog in
Avatar of BabyFace
BabyFace

asked on

SetTimer

Hi,

When setting a Timer using the API func. SetTimer,
How can you make sure that the handle of the timer you're
providing isn't already in use?
Is there a function that returns the next valid timer handle?
Something like FreeFile???

Thanks in advance
Avatar of mrmick
mrmick

The SetTimer API function creates a timer, the return value is a long integer identifying the new timer.  It is unique.

There is a Timer control with VB - it's easier to use.
whoops,

If the return value is zero, the function failed.
Avatar of BabyFace

ASKER

Hi,

Perhapse I should make my question a little clearer.
Sorry.

This is the definition of SetTimer:
Declare Function SetTimer Lib "user32" Alias "SetTimer" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long

How do I find the next valid timer identifier?
because what if you did this?
SetTimer me.hwnd,1,1000,addressof Myfunc
[in another function]
SetTimer me.hwnd,1,1000,addressof MyFunc2
[destory event]
KillTimer 1
???? What about the other timer?????
As I said, the timer function RETURNS a long integer identifying the new timer. It is unique.  When set the timer like this:

TimerID = SetTimer me.hwnd,1,1000,addressof Myfunc

And release it:

Kill TimerID

The second argument in you're example (1) is the EVENT ID

Quote:
TimerID = SetTimer me.hwnd,1,1000,addressof Myfunc
And release it:
Kill TimerID

I suppose you ment KillTimer TimerID right?
But the description of the KillTimer say that it receives a windows hwnd  and the timer identifier
not the timer handle.
So how do you find the next valid timer handle.?

ASKER CERTIFIED SOLUTION
Avatar of mrmick
mrmick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial