Error C2664: "MessageBoxW": Cannot convert parameter 2 from "const char [14]" to "LPCWSTR"

Source: Internet
Author: User
VS2008 tip error C2664: "Cwnd::messageboxw": Cannot convert parameter 1 from "const char [17]" to "LPCTSTR"

In the outside to write MFC program with VS2005 often to the MessageBox ("hint message") function, in the vc6.0 is no problem, but in VS2005 will have the following hint:

Error C2664: "Cwnd::messageboxw": Cannot convert parameter 1 from "const char [17]" to "LPCTSTR"

The reason for this error is that VS2005 uses the Unicode character set by default, and errors occur when the parameter is converted

The workaround is simple.

Method One:

MessageBox (_t("You have submitted success. "));

That is, add _t before the parameter

Method Two:

When you create a new project, the use of the Unicode character set is canceled, such as:

Method Three:

Select "Project"-"XXX Project Properties"-"Configuration Properties"-"general" option, change "character set" to "use multibyte Character set" and then OK. Such as:

Error C2664: "MessageBoxW": Cannot convert parameter 2 from "const char [14]" to "LPCWSTR"

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.