Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to reset Timers

How to reset Timers

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gc_1
    wrote on last edited by
    #1

    Hi, Can I reset a Timer without doing a KillTimer? For example if I created a Timer as oldTimer = SetTimer(0, 2000, NULL); later SetTimer(oldTimer, 5000, NULL); Is this going to reset the Timer to the new time. Thanks, gc

    P J M 3 Replies Last reply
    0
    • G gc_1

      Hi, Can I reset a Timer without doing a KillTimer? For example if I created a Timer as oldTimer = SetTimer(0, 2000, NULL); later SetTimer(oldTimer, 5000, NULL); Is this going to reset the Timer to the new time. Thanks, gc

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      I don't know, try it and find out and let us all know.


      [

      ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

      1 Reply Last reply
      0
      • G gc_1

        Hi, Can I reset a Timer without doing a KillTimer? For example if I created a Timer as oldTimer = SetTimer(0, 2000, NULL); later SetTimer(oldTimer, 5000, NULL); Is this going to reset the Timer to the new time. Thanks, gc

        J Offline
        J Offline
        Jack_pt
        wrote on last edited by
        #3

        It has been a while since I played around with them but I'm pretty sure that if you try SetTimer as you suggested, the second one will fail since the timer with the given id has already been allocated. You can check the return value for yourself to be sure though.

        1 Reply Last reply
        0
        • G gc_1

          Hi, Can I reset a Timer without doing a KillTimer? For example if I created a Timer as oldTimer = SetTimer(0, 2000, NULL); later SetTimer(oldTimer, 5000, NULL); Is this going to reset the Timer to the new time. Thanks, gc

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          From MSDN:

          If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored.

          So there's no need to "reset" a timer (which you can't actually do anyway, you can only create it or kill it). --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

          G 1 Reply Last reply
          0
          • M Michael Dunn

            From MSDN:

            If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored.

            So there's no need to "reset" a timer (which you can't actually do anyway, you can only create it or kill it). --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

            G Offline
            G Offline
            gc_1
            wrote on last edited by
            #5

            Michael, thanks for your response. I tested with the example program and WM_TIMER message is sent after the current time-out value elapsed.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups