为什么C ++中的消息框显示中文消息 [英] Why does message box in C++ show chinese message
本文介绍了为什么C ++中的消息框显示中文消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在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字符串常量'将不会帮助,并导致内存位置的不正确解释。
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 ++中的消息框显示中文消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文