Troubleshoot C + + methods that cannot be converted from void to lresult _c language

Source: Internet
Author: User
This should be an MFC program, On_message is to add a message response function, this sentence is to add a hotkey wm_hotkey response function. When you register the hotkey, when the user presses the hot key, the Onhotkey function is executed to process the message. The error should be onhotkey the declaration of this function is wrong, the return value should be lresult. VS2008 the message is more stringent inspection, previously in VC6 completely normal operation of the message map under the VS2008 compiler does not pass

On_message (Wm_message,onmymessage);
The OnMessage return value must be lresult in the form of: afx_msg lresult OnMessage (WPARAM, LPARAM);
If it does not, then there is an error message: Error C2440: "static_cast": Cannot convert from "void" (__thiscall cmainframe::*) (void) to Lresult (__thiscall cwnd::* ) (Wparam,lparam) "

The solution is as follows: first, change the original message function return value type to LRESULT, the function can be casually written back 0, and then the message function parameters must be rewritten (WPARAM Wparam,lparam LPARAM) Regardless of these two.

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.