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. Using a Timer in a Subclassed Control

Using a Timer in a Subclassed Control

Scheduled Pinned Locked Moved C / C++ / MFC
questionworkspace
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.
  • M Offline
    M Offline
    MJ_Karas
    wrote on last edited by
    #1

    I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike

    J M 2 Replies Last reply
    0
    • M MJ_Karas

      I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Call SetTimer in CYourEdit::OnCreate. Kill the timer in CYourEdit::OnDestroy (or alternatively, let the timer be killed by the system upon window destruction). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      N 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        Call SetTimer in CYourEdit::OnCreate. Kill the timer in CYourEdit::OnDestroy (or alternatively, let the timer be killed by the system upon window destruction). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        ... and before all that, read this article about timers :) I vote pro drink :beer:

        M 1 Reply Last reply
        0
        • M MJ_Karas

          I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          WM_CREATRE and WM_DESTROY are good place Mazy Don't Marry a Person You Can Live With... Marry Someone You Can Not Live Without

          1 Reply Last reply
          0
          • N Nemanja Trifunovic

            ... and before all that, read this article about timers :) I vote pro drink :beer:

            M Offline
            M Offline
            MJ_Karas
            wrote on last edited by
            #5

            Thankyou All that replied on the Timer issue. And thx esp to Nemanja for the link to the timers article. Mike ;)

            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