views:

626

answers:

2

When I created my visual studio project it defaulted to forcing me to use wide strings for all the functions which take character strings. MessageBox() for example, takes a LPCWSTR rather than a const char*. While I understand that it's great for multi-lingual and portable applications, it is completely unnecessary for my simple little app. Quite frankly, it's more of a pain to constantly type TEXT() around all my strings.

Is there a compiler option, define or project setting which I can alter to fix this in my Visual Studio project?

+5  A: 

Right click on your project -> Properties then go to the following tree item:

Configuration Properties -> General

For Unicode select:
Use Unicode Character Strings

For normal multi-byte select:
Use Multi-Byte Character Set

When you put TEXT() or _T() around your strings, you are making it compatible with both of the character string options. If you select Use multi-byte character set then you do not need anything around your strings. If you select Use unicode character set, you need at least L in front of your strings.

By selecting Use Unicode Character Strings you are also by default using all of the Win32 API that end in W. Example: MessageBox maps to MessageBoxW.

When you select Use multi-byte character set you are also by default using all of the Win32 API that end in A. Example: MessageBox maps to MessageBoxA.

Brian R. Bondy
A: 

It is worth noting that you can explicitly declare wide character string literals of the form:

WCHAR *s = L"Hello Wide World.";

which requires fewer keystrokes than the macros TEXT() or _T(), but which will make a wide character string even if UNICODE is not defined.

Matthew Xavier