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. ATL / WTL / STL
  4. How to get timer id from onTimer() in WTL

How to get timer id from onTimer() in WTL

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++helptutorial
10 Posts 2 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.
  • J Offline
    J Offline
    josip cagalj
    wrote on last edited by
    #1

    Hi, I'm working on some test app and i need help. I'm using vs2008 wtl. I add an handler for timer functionality and it looks like: MESSAGE_HANDLER(WM_TIMER, OnTimer), and implementationLRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); Unlike old MSG_WM_TIMER(OnTimer)and implementation void OnTimer ( UINT uTimerID, TIMERPROC pTimerProc ) My question how can I get timer id out from param's in 'new' MESSAGE_HANDLER ontimer f.? Thanks in advance

    S 1 Reply Last reply
    0
    • J josip cagalj

      Hi, I'm working on some test app and i need help. I'm using vs2008 wtl. I add an handler for timer functionality and it looks like: MESSAGE_HANDLER(WM_TIMER, OnTimer), and implementationLRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); Unlike old MSG_WM_TIMER(OnTimer)and implementation void OnTimer ( UINT uTimerID, TIMERPROC pTimerProc ) My question how can I get timer id out from param's in 'new' MESSAGE_HANDLER ontimer f.? Thanks in advance

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Look at the documentation[^] - wParam == timer ID. So, uncomment the relevant parameter's name in your implementation and use it. You should have something like this:LRESULT OnTimer(UINT /*uMsg*/, WPARAM _wParam_, LPARAM /*lParam*/, BOOL& /*bHandled*/);
      or you could even alter the parameter's name to be more descriptive...LRESULT OnTimer(UINT /*uMsg*/, WPARAM _timerID_, LPARAM /*lParam*/, BOOL& /*bHandled*/);

      J 1 Reply Last reply
      0
      • S Stuart Dootson

        Look at the documentation[^] - wParam == timer ID. So, uncomment the relevant parameter's name in your implementation and use it. You should have something like this:LRESULT OnTimer(UINT /*uMsg*/, WPARAM _wParam_, LPARAM /*lParam*/, BOOL& /*bHandled*/);
        or you could even alter the parameter's name to be more descriptive...LRESULT OnTimer(UINT /*uMsg*/, WPARAM _timerID_, LPARAM /*lParam*/, BOOL& /*bHandled*/);

        J Offline
        J Offline
        josip cagalj
        wrote on last edited by
        #3

        Thanks once again Stuart, indeed I've done so. UINT uTimerID = (UINT)wParam; Similarly I've get HDC out from WM_ERASEBKGND implementer; HDC hdc = (HDC)wParam; One question do, I'm getting error on my CRect member: "error C2065: 'CRect' : undeclared identifier" ??? Do I need additional include?

        J S 2 Replies Last reply
        0
        • J josip cagalj

          Thanks once again Stuart, indeed I've done so. UINT uTimerID = (UINT)wParam; Similarly I've get HDC out from WM_ERASEBKGND implementer; HDC hdc = (HDC)wParam; One question do, I'm getting error on my CRect member: "error C2065: 'CRect' : undeclared identifier" ??? Do I need additional include?

          J Offline
          J Offline
          josip cagalj
          wrote on last edited by
          #4

          By including 'atltypes.h'

          1 Reply Last reply
          0
          • J josip cagalj

            Thanks once again Stuart, indeed I've done so. UINT uTimerID = (UINT)wParam; Similarly I've get HDC out from WM_ERASEBKGND implementer; HDC hdc = (HDC)wParam; One question do, I'm getting error on my CRect member: "error C2065: 'CRect' : undeclared identifier" ??? Do I need additional include?

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            CRect is defined in atltypes.h in ATL in Visual Studio 2003, 2005 and 2008, or alternatively in atlmisc.h in WTL - if you're using one of those Visual Studio versions, I'd #include atltypes.h rather than atlmisc.h.

            J 1 Reply Last reply
            0
            • S Stuart Dootson

              CRect is defined in atltypes.h in ATL in Visual Studio 2003, 2005 and 2008, or alternatively in atlmisc.h in WTL - if you're using one of those Visual Studio versions, I'd #include atltypes.h rather than atlmisc.h.

              J Offline
              J Offline
              josip cagalj
              wrote on last edited by
              #6

              THANKS! I've included atltypes.h now complaining about "error C2079: 'sTime' uses undefined class 'WTL::CString'" sTime - is my CString variable I have #define _WTL_USE_CSTRING in my stdafx.h

              J S 2 Replies Last reply
              0
              • J josip cagalj

                THANKS! I've included atltypes.h now complaining about "error C2079: 'sTime' uses undefined class 'WTL::CString'" sTime - is my CString variable I have #define _WTL_USE_CSTRING in my stdafx.h

                J Offline
                J Offline
                josip cagalj
                wrote on last edited by
                #7

                Just remove my include 'atltypes.h' instead included 'atlmisc.h' no error now!

                1 Reply Last reply
                0
                • J josip cagalj

                  THANKS! I've included atltypes.h now complaining about "error C2079: 'sTime' uses undefined class 'WTL::CString'" sTime - is my CString variable I have #define _WTL_USE_CSTRING in my stdafx.h

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #8

                  See the "WTL CString support" section on this page[^] - you're probably better off using ATL's CString rather than WTL's, as ATL's CString is (now) MFC's CString, so may be more fully featured and optimised?

                  J 1 Reply Last reply
                  0
                  • S Stuart Dootson

                    See the "WTL CString support" section on this page[^] - you're probably better off using ATL's CString rather than WTL's, as ATL's CString is (now) MFC's CString, so may be more fully featured and optimised?

                    J Offline
                    J Offline
                    josip cagalj
                    wrote on last edited by
                    #9

                    Thanks, I've read the article and I must say it's a little ambiguous. Why couldn't I just leave it as is (including atlmisc.h) is it wrong? Everything is compiling ok?!

                    S 1 Reply Last reply
                    0
                    • J josip cagalj

                      Thanks, I've read the article and I must say it's a little ambiguous. Why couldn't I just leave it as is (including atlmisc.h) is it wrong? Everything is compiling ok?!

                      S Offline
                      S Offline
                      Stuart Dootson
                      wrote on last edited by
                      #10

                      You can - I'm just pointing out the options :-) I suspect that the WTL CString is no longer developed (I could be wrong), whereas the ATL/MFC CString is as mainstream as C++ gets in Microsoft development.

                      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