The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Lightman on March 05, 2008, 11:46:57 AM

Title: Can't stop a timer!
Post by: Lightman on March 05, 2008, 11:46:57 AM
Hi Everybody,

I am writing a bit of code to play with timers.  I create the timer OK and can run code under the WM_TIMER event, but I cannot stop the timer.  I would like my code to be able to start and stop the timer, so my program has a 'Off' button that kills the timer.  I call the KillTimer call but the timer won't stop! It just keeps on going. Can anyone advise on how I should be using timers?

Regards,

Lightman

Title: Re: Can't stop a timer!
Post by: MichaelW on March 05, 2008, 12:28:42 PM
If KillTimer is not stopping the timer then the likely cause is that one of the parameters is wrong. If you specified a window handle and a timer id in the call to SetTimer, then you must pass the same handle and the same id to KillTimer. If you did not specify a window handle in the call to SetTimer, then the system assigns the timer id, and you must pass the id that SetTimer returned to KillTimer.
Title: Re: Can't stop a timer!
Post by: Lightman on March 05, 2008, 12:50:59 PM
Cheers for that, I got it working now.

I found it a little confusing. It seems some of the parameters are optional depending on how the timer is created.

Regards,

Lightman