Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I create a win32 project. And write messageBox function. when run it, lpText parameter show in chinese.how is fix that?

MessageBox(NULL,(LPCWSTR) "only select 1 / 2!\nif you want to cancel edit press 0",(LPCWSTR)"Note",MB_OK);
Posted

you're casting a narrow string to a wide string

wrap the text in the _T() macro

MessageBox(NULL, _T("text1"), _T("text2"), MB_OK);
 
Share this answer
 
v2
Comments
alirezamilani 29-Jul-12 3:14am    
not fix it. i think that it be from setting.right?
Solution 1 will work.
Or you can use MessageBoxA instead of MessageBox and please stop typecasting.
It is evil.
 
Share this answer
 
Comments
alirezamilani 29-Jul-12 3:22am    
fix it.thx a lot
alirezamilani wrote:
(LPCWSTR) "only select 1 / 2!\nif you want to cancel edit press 0"

That is EVIL and (the programmers) God is punishing you.

See "The Complete Guide to C++ Strings, Part I - Win32 Character Encodings"[^].
 
Share this answer
 
You are using LPCWSTR casts on ASCII character strings so the system thinks those strings are in Unicode. This is not a good thing to do; remove the casts and it should work.
 
Share this answer
 
Instead of "only select... use L"only select...
Windows programs are UNICODE unless explicitly used ASCII. So read more about UNICODE.
 
Share this answer
 
you should use _T("") to tell compiler you are using unicode.
by the way ,that's not chinese,may be some messy code that looks like chinese
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900