Reprint to: http://www.educity.cn/wenda/566627.html
Error C2440 "static_cast" cannot convert from "void (__thiscall) (void)" to "LRESULT
Error C2440
"Static_cast" cannot convert from "void (__thiscall Cpppview) (void)" to "LRESULT (__thiscall CWnd) (Wparam,lparam)"
Cannot convert void (_thiscall CMainFrame::*) (void) to LRESULT (__thiscall CWnd::*) (Wparam,lparam) The development platform is upgraded from VC6.0 to VS2005, and the original project needs to be migrated.
You may encounter a similar error:
Error C2440: ' static_cast ': cannot convert from ' void (__thiscall CMainFrame::*)
(void) ' to ' LRESULT (__thiscall CWnd::*) (Wparam,lparam) '
VS2005 the message is more stringent, the message map that was previously fully operational under VC6 is not compiled under VS2005
On_message (Wm_message,onmymessage);
The OnMyMessage return value must be LRESULT in the form: afx_msg LRESULT onmymessage (WPARAM, LPARAM), and if not, there is an error message:
Error C2440: "static_cast": Cannot convert from "void (__thiscall Cpppview::*) (Wparam,lparam)" to "LRESULT (__thiscall CWnd::*) (WPARAM, LPARAM) "Does not have a function with that name in the range that matches the target type
Error C2440: "static_cast": Cannot convert from "void (__thiscall Cpppview::*) (void)" to "LRESULT (__thiscall CWnd::*) (Wparam,lparam)" in There is no function with that name in the range that matches the target type
Here's how to fix it:
For example: TransparentWnd.cpp in On_message (wm_liben,onliben):
First: Change the original message function return value type to LRESULT (find Onliben definition, such as Viod Ctransparentwnd::onliben (WPARAM wparam,lparam LPARAM) to Lresult Ctransparentwnd::onliben (WPARAM wparam,lparam LPARAM), the declaration office will also be changed, such as Afx_msg LRESULT Onliben (WPARAM wparam,lparam LPARAM);) ;
Second: The function can be written in a random return TRUE;
Third: Then the parameters of the message function must be rewritten (WPARAM Wparam,lparam LPARAM) Regardless of whether the two parameters are used;
IV: Message maps such as On_message (wm_message,& onmymessage)
Message Passing MFC error C2440 "static_cast" cannot convert from "void (_thiscall) (void)" to "LRESULT