MessageBox not resolving to MessageBoxW?
Scenario 1 I created an empty vc开发者_如何学Python++ project added a c file to it and the #include. Now in my main() function if I hover my mouse over the MessageBox func., it resolves to MessageBoxA.
Scenario 2 I create a win32 windows project now here MessageBox resolves to MessageBoxW??? I checked the Project properties->c/c++->preprocessor property there I found WIN32 defined so I did that in my previous project but still the same result.
What should I do.Yeah of course I can use the latter type of project but think of me as one stubborn rookie who wants to learn the tid-bits.
thanks.
The default "Character Set" property for a new empty project is "Multi-Byte", which means that the preprocessor will not define the UNICODE
preprocessor symbol and so MessageBox
will be replaced by MessageBoxA
.
For a Win32 project, the default "Character Set" property is "Unicode", which means the preprocessor will define UNICODE
and thus MessageBox
will be replaced by MessageBoxW
.
See the MSDN article Working with Strings for an introduction.
This is determined by the presence or otherwise of the UNICODE conditional which is determined by the project configuration: either Unicode or Multi-byte character set.
Project + Properties, Configuration Properties, General. It is the Character Set property. Only create empty projects after you figured out how everything works. Albeit that the quickest way to learn is by making all the mistakes.
General recommendation: always use MessageBoxW(). There's very little reason to compile your program with MBCS setting, which literally means "textually broken".
精彩评论