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. SetTimer

SetTimer

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
6 Posts 5 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.
  • Z Offline
    Z Offline
    ZarrinPour
    wrote on last edited by
    #1

    Hi: As you know "SetTimer" has the following syntax: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc); // timer procedure I have problem with first parameter.i used m_hWnd (public member),but it doesn't work!!!.now in my MFC application,what should i choose for first parameter ? in the other hand how can i get a handle to the form or dialog's window ? please help me. Best Regards.

    R T M D 4 Replies Last reply
    0
    • Z ZarrinPour

      Hi: As you know "SetTimer" has the following syntax: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc); // timer procedure I have problem with first parameter.i used m_hWnd (public member),but it doesn't work!!!.now in my MFC application,what should i choose for first parameter ? in the other hand how can i get a handle to the form or dialog's window ? please help me. Best Regards.

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      In MFC, SetTimer() is a CWnd method. Just call it in your dialog's OnInitDialog() or in your CFormView's OnInitialUpdate(). /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

      1 Reply Last reply
      0
      • Z ZarrinPour

        Hi: As you know "SetTimer" has the following syntax: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc); // timer procedure I have problem with first parameter.i used m_hWnd (public member),but it doesn't work!!!.now in my MFC application,what should i choose for first parameter ? in the other hand how can i get a handle to the form or dialog's window ? please help me. Best Regards.

        T Offline
        T Offline
        Toni78
        wrote on last edited by
        #3

        HWND GetDlgItem( int nID ) will give you the window handle. You could actually use CWnd::SetTimer which doesn't require a handle as a parameter. UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) ); For your Callback function you can have a NULL parameter and you can handle WM_TIMER instead or CWnd::OnTimer(UINT nIDEvent ); // Afterall I realized that even my comment lines have bugs

        1 Reply Last reply
        0
        • Z ZarrinPour

          Hi: As you know "SetTimer" has the following syntax: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc); // timer procedure I have problem with first parameter.i used m_hWnd (public member),but it doesn't work!!!.now in my MFC application,what should i choose for first parameter ? in the other hand how can i get a handle to the form or dialog's window ? please help me. Best Regards.

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

          What do you mean "it doesn't work"? It won't compile? It formats your drive? When you call SetTimer in a window class, you use CWnd::SetTimer, which doesn't take an HWND parameter. --Mike--    THERE IS NO     THERE IS NO    BUT THERE IS MAGIC PIXIE DUST  BUSINESS GENIE  CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

          R 1 Reply Last reply
          0
          • M Michael Dunn

            What do you mean "it doesn't work"? It won't compile? It formats your drive? When you call SetTimer in a window class, you use CWnd::SetTimer, which doesn't take an HWND parameter. --Mike--    THERE IS NO     THERE IS NO    BUT THERE IS MAGIC PIXIE DUST  BUSINESS GENIE  CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            Michael Dunn wrote: It formats your drive? Bad day @ work, Mike? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

            1 Reply Last reply
            0
            • Z ZarrinPour

              Hi: As you know "SetTimer" has the following syntax: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // timer identifier UINT uElapse, // time-out value TIMERPROC lpTimerFunc); // timer procedure I have problem with first parameter.i used m_hWnd (public member),but it doesn't work!!!.now in my MFC application,what should i choose for first parameter ? in the other hand how can i get a handle to the form or dialog's window ? please help me. Best Regards.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              MR ZarrinPour wrote: now in my MFC application,what should i choose for first parameter ? Have a look at GetSafeHwnd(), although CWnd::SetTimer() is probably what you should be using.

              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