How to get timer id from onTimer() in WTL
-
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 oldMSG_WM_TIMER(OnTimer)
and implementationvoid 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 -
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 oldMSG_WM_TIMER(OnTimer)
and implementationvoid 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 advanceLook 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*/);
-
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*/);
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? -
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?By including 'atltypes.h'
-
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?CRect
is defined inatltypes.h
in ATL in Visual Studio 2003, 2005 and 2008, or alternatively inatlmisc.h
in WTL - if you're using one of those Visual Studio versions, I'd#include
atltypes.h
rather thanatlmisc.h
. -
CRect
is defined inatltypes.h
in ATL in Visual Studio 2003, 2005 and 2008, or alternatively inatlmisc.h
in WTL - if you're using one of those Visual Studio versions, I'd#include
atltypes.h
rather thanatlmisc.h
.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 -
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.hJust remove my include 'atltypes.h' instead included 'atlmisc.h' no error now!
-
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 -
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?!
-
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?!
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/MFCCString
is as mainstream as C++ gets in Microsoft development.