QuickWin
-
I downloaded the QuickWin example and opened the .sln file with "MS Visual C++ .net 2003". It asked to convertthe files, which I did. It compiled with the following error: QuickWin.cpp(195) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CQuickWinApp::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)' I had a buddy try it under VC++ 6 and he had no problems. Does anyone have any ideas or pointers. Thanks DCrawford999
-
I downloaded the QuickWin example and opened the .sln file with "MS Visual C++ .net 2003". It asked to convertthe files, which I did. It compiled with the following error: QuickWin.cpp(195) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CQuickWinApp::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)' I had a buddy try it under VC++ 6 and he had no problems. Does anyone have any ideas or pointers. Thanks DCrawford999
With VC7 user defined message handlers have to return an LRESULT, they can no longer be void functions. VC6 allowed void functions.
// in message map
ON_MESSAGE (WM_MYMESSAGE, OnMyMessage)// VC6
void CMyApp::OnMyMessage(WPARAM wp, LPARAM lp)
{
// whatever
}// VC7
LRESULT CMyApp::OnMyMessage(WPARAM wp, LPARAM lp)
{
// whatever
return 0;
}
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
-
With VC7 user defined message handlers have to return an LRESULT, they can no longer be void functions. VC6 allowed void functions.
// in message map
ON_MESSAGE (WM_MYMESSAGE, OnMyMessage)// VC6
void CMyApp::OnMyMessage(WPARAM wp, LPARAM lp)
{
// whatever
}// VC7
LRESULT CMyApp::OnMyMessage(WPARAM wp, LPARAM lp)
{
// whatever
return 0;
}
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
The void is coming from afxmsg.h dealing ON_REGISTERED_THREAD_MESSAGE but I am not sure how too clear up the conflict. ON_REGISTERED_THREAD_MESSAGE(WM_STDIO_COMMAND, OnStdioCommand) // for Thread messages #define ON_THREAD_MESSAGE(message, memberFxn) \ { message, 0, 0, 0, AfxSig_vwl, \ (AFX_PMSG)(AFX_PMSGT) \ (static_cast< void (AFX_MSG_CALL CWinThread::*)(WPARAM, LPARAM) > \ (memberFxn)) }
-
The void is coming from afxmsg.h dealing ON_REGISTERED_THREAD_MESSAGE but I am not sure how too clear up the conflict. ON_REGISTERED_THREAD_MESSAGE(WM_STDIO_COMMAND, OnStdioCommand) // for Thread messages #define ON_THREAD_MESSAGE(message, memberFxn) \ { message, 0, 0, 0, AfxSig_vwl, \ (AFX_PMSG)(AFX_PMSGT) \ (static_cast< void (AFX_MSG_CALL CWinThread::*)(WPARAM, LPARAM) > \ (memberFxn)) }
Read the first 200 lines of AfxSig_.h. It explains a lot of how the naming convention of functions work.
AfxSig_vwl = AfxSig_v_w_l, // void (UINT, LPARAM)
means your OnStdioCommand prototype has to be
void CMyWinThread::OnStdioCommand(UINT uInt, LPARAM lParam)
I hope this helps.
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
-
Read the first 200 lines of AfxSig_.h. It explains a lot of how the naming convention of functions work.
AfxSig_vwl = AfxSig_v_w_l, // void (UINT, LPARAM)
means your OnStdioCommand prototype has to be
void CMyWinThread::OnStdioCommand(UINT uInt, LPARAM lParam)
I hope this helps.
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
If I change it to a VOID and remove the return, I get: QuickWin.cpp(196) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CQuickWinApp::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)' None of the functions with this name in scope match the target type DCrawford999
-
If I change it to a VOID and remove the return, I get: QuickWin.cpp(196) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CQuickWinApp::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)' None of the functions with this name in scope match the target type DCrawford999
Did you also change the function prototype in the header file? Look up C2440 in MSDN for more info on the error message. I am starting to guess here, as I do not have your code in front of me
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
-
Did you also change the function prototype in the header file? Look up C2440 in MSDN for more info on the error message. I am starting to guess here, as I do not have your code in front of me
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Many thanks. I forgot to change the prototype (rookie mistake). DCrawford999