Error C2440: ' static_cast ': cannot convert from ' void (__thiscall CMainFrame::*) (void) ' to ' Lresul

Source: Internet
Author: User
Cannot convert void (_thiscall CMainFrame::*) (void) to Lresult (__thiscall CWnd::*) (Wparam,lparam)
The development platform is upgraded from VC6.0 to VS2005, the original project needs to be migrated, and a similar error may be encountered:
Error C2440: ' static_cast ': cannot convert from ' void (__thiscall CMainFrame::*) (void) ' to ' Lresult (__thiscall CWnd::* ) (Wparam,lparam) '

VS2005 the message is more stringent inspection, previously in VC6 completely normal operation of the message map under the VS2005 compiler does not pass

On_message (Wm_message,onmymessage);
The OnMyMessage return value must be lresult, in the form of: afx_msg lresult OnMyMessage (WPARAM, LPARAM) and, if not, an error message:
Error C2440: "static_cast": Cannot convert from "void" (__thiscall Cpppview::*) (Wparam,lparam) to Lresult (__thiscall CWnd::*) (WPARAM, LPARAM) "
There is no 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)
There is no function with that name in the range that matches the target type

The workaround is as follows:

First, the original message function return value type is changed to Lresult, the function can be arbitrarily written to TRUE; The parameters of the message function must then be rewritten (WPARAM Wparam,lparam LPARAM) Regardless of whether the two parameters are used or not, and finally, the message map, such as On_message (wm_message,& onmymessage)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.