可能的重复:
为什么我的简单 C++ GUI应用程序显示中文消息框?
我已经在 Visual C++ 中实现了如下代码块:
I have implemented this block of code as below in Visual C++:
int nResult=MessageBox(NULL,
(LPCWSTR)"An example of Cancel,Retry,Continue",
(LPCWSTR)"Message Box!",
MB_ICONWARNING|MB_ABORTRETRYIGNORE);
然而,无论我尝试什么,它总是显示一个中文消息框!因此,我只想为我的问题寻求任何解决方案以及为什么这里有中文信息.谢谢!
however, no matter what i tried, it always show a message box in chinese! Therefore, i just want to ask for any solution for my problem and why there is chinese message here. Thanks you!
您忘记在字符串字面量之前放置 'L'.修改如下:
You forgot to place 'L' before the string literal. Modify as follows:
int nResult=MessageBox(NULL,
L"An example of Cancel,Retry,Continue",
L"Message Box!",
MB_ICONWARNING|MB_ABORTRETRYIGNORE);
在 C++ 中,Unicode 字符串文字以 L 为前缀.如果您不添加前缀,则转换为unicode string constant"将无济于事,并会导致对内存位置的错误解释.
In C++ unicode string literals are prefixed with L. If you don't put the prefix, casting to 'unicode string constant' won't help and causes incorrect interpreting of the memory location.
这篇关于为什么C++中的消息框显示中文消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
为什么两个函数的地址相同?Why do two functions have the same address?(为什么两个函数的地址相同?)
为什么 std::function 的初始化程序必须是可复制构Why the initializer of std::function has to be CopyConstructible?(为什么 std::function 的初始化程序必须是可复制构造的?)
混合模板与多态性mixing templates with polymorphism(混合模板与多态性)
我什么时候应该使用关键字“typename"?使用模When should I use the keyword quot;typenamequot; when using templates(我什么时候应该使用关键字“typename?使用模板时)
依赖名称解析命名空间 std/标准库Dependent name resolution amp; namespace std / Standard Library(依赖名称解析命名空间 std/标准库)
gcc 可以编译可变参数模板,而 clang 不能gcc can compile a variadic template while clang cannot(gcc 可以编译可变参数模板,而 clang 不能)