I'm assuming the reader has done some user defined messages in MFC.
In previous versions of Visual c++ (6.0), message handlers for On_Message and On_Command messages could be used interchangeably because of the macro that defined On_message in afxmsg_.h. The old macro code is as follows:
whereby the return value of the message handler is cast to the appropriate type for On_message, which requires a LRESULT returned from the handler, or a AFX_PMSG for the On_command.
However in c++.net the macro now uses a static cast and this may cause problems when you try to port a MFC program to c++.net; the new macro is shown below
// for Windows messages, from afxmsg_.h
#define ON_MESSAGE(message, memberFxn) { message, 0, 0, 0, AfxSig_lwl, (AFX_PMSG)(AFX_PMSGW) (static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM) > (memberFxn)) },
If you have used message handlers interchangeably for both On_command and On_message in VC++ 6, compiling your code in .net will generate a C2440 error: 'static_cast' : cannot convert from 'void* (__thiscall CStethoSoftView::* )(void)' to LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM)'.
The declaration for my message handler is:
afx_msg void OnPlay();
Two options are now available, one is that you revert the afxmsg_.h to the old macro (which I do not recommend) or explicitly cast the handler to the LRESULT type needed in On_message.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.