CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 1999
    Posts
    22

    Changing SetTimer interval

    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.


  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: Changing SetTimer interval

    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


  3. #3
    Join Date
    Jun 1999
    Posts
    22

    Re: Changing SetTimer interval

    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?


  4. #4
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: Changing SetTimer interval

    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
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

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

Featured