0

I am using wxWidgets 2.9.4 in Visual Studio 2012 and I keep getting these two error messages:

Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'

IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

My code is:

#ifdef _WIN32
    std::string msg;
    StringFromFormatV(&msg, format, args);
    retval = IDYES == MessageBox(0, msg.c_str(), "ERROR! Continue?", MB_ICONQUESTION | MB_YESNO);
  • possible duplicate of [cannot convert parameter 2 from 'const char \[14\]' to 'LPCWSTR'](http://stackoverflow.com/questions/15592906/cannot-convert-parameter-2-from-const-char-14-to-lpcwstr) – tinman Jul 14 '13 at 19:55
  • In addition to the solution below, why do you use Win32 `::MessageBox()` anyhow if you're using wxWidgets? Just use `wxMessageBox()` instead. – VZ. Jul 15 '13 at 13:08

1 Answers1

1

You are compiling your project using multi-byte characters as default. You can change that in your project's properties, or you can use msg.wc_str(), or even enforce the use of MessageBoxA instead of using the macro MessageBox.

Havenard
  • 27,022
  • 5
  • 36
  • 62