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. Timers in an MSDI app

Timers in an MSDI app

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • D Offline
    D Offline
    Daniel1324
    wrote on last edited by
    #1

    I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!

    P J 2 Replies Last reply
    0
    • D Daniel1324

      I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!

      P Offline
      P Offline
      Peter Molnar
      wrote on last edited by
      #2

      Use KillTimer(m_nTimerID); Peter Molnar

      D 1 Reply Last reply
      0
      • P Peter Molnar

        Use KillTimer(m_nTimerID); Peter Molnar

        D Offline
        D Offline
        Daniel1324
        wrote on last edited by
        #3

        Thanks for the reply, but that wasnt my question.

        P 1 Reply Last reply
        0
        • D Daniel1324

          Thanks for the reply, but that wasnt my question.

          P Offline
          P Offline
          Peter Molnar
          wrote on last edited by
          #4

          SetTimer is CWnd's member function, happens nothing extraordinary (i.e. no memory leak or anything bad) if you don't kill it separately. The framework does this for you when the CWnd object gets destroyed from which you called it regardless whether you called it from your view or framewnd or whatever place. As for handling WM_CLOSE in your mainframe, this is a good place for things to clean up that require clean up. Peter Molnar

          D 1 Reply Last reply
          0
          • P Peter Molnar

            SetTimer is CWnd's member function, happens nothing extraordinary (i.e. no memory leak or anything bad) if you don't kill it separately. The framework does this for you when the CWnd object gets destroyed from which you called it regardless whether you called it from your view or framewnd or whatever place. As for handling WM_CLOSE in your mainframe, this is a good place for things to clean up that require clean up. Peter Molnar

            D Offline
            D Offline
            Daniel1324
            wrote on last edited by
            #5

            Thanks! Thats what I needed!

            1 Reply Last reply
            0
            • D Daniel1324

              I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!

              J Offline
              J Offline
              John R Shaw
              wrote on last edited by
              #6

              I notice that Peter Molnar gave you the answer, but I consider it a good practice to kill the timers youself instead of depending on the frame work to do it. One of the reasons for this is that you have control and can close it when it is know longer needed, instead of letting it run after its' job is done. The second reason is that unless it is need to run during the life time of the object, it should be killed because it is still generating timer messages and wasting processor time. INTP

              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