Click to See Complete Forum and Search --> : Changing SetTimer interval
snuftech
June 7th, 1999, 09:21 AM
Hi,
I'm using SetTimer in my Dialog based program. One of the options I need to have is to change the timer interval. I wrote the code for changing the number, but how do I reset the SetTimer to use the new interval, if it is running continuously in the background??
If you have any ideas please let me know.
Thanks, Ron.
ChrisD
June 7th, 1999, 09:58 AM
Set a flag that it needs to be changed and in the next Timer event and call SetTimer again with the new time.
HTH,
Chris
snuftech
June 7th, 1999, 10:37 AM
How?
I have my SetTimer in OnInitDialog. Once the 'user' pushes a button to change the interval, a new dialog is opened to input the new interval. After IDOK, the interval variable (A global) value is changed to the new one. Is my SetTimer in the wrong place? if not, How do I set a flag for it to modify the interval?
Roger Allen
June 7th, 1999, 11:29 AM
You only have to kill the old timer and create a new one with the new time interval. When your dialog receives the OnTimer() message, you are given the ID of the timer. If you only have 1 timer in your app, there is no need to change your code, but if you have more then 1 you will have to create the new timer with the same ID number as the one you killed.
Just after getting the new value you could do the following code :
KillTimer(m_TimerID) ; // from when you used SetTimer in OnInitDialog()
m_TimerID = SetTimer(1, NewTime, NULL) ; // to use the new time value
HTH
Roger Allen
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.