MessageBoxW cannot convert

 ̄綄美尐妖づ 提交于 2019-12-13 07:07:06

问题


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);

回答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.



来源:https://stackoverflow.com/questions/17643122/messageboxw-cannot-convert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!