开发者

MessageBox not resolving to MessageBoxW?

开发者 https://www.devze.com 2023-02-07 23:15 出处:网络
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 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".

0

精彩评论

暂无评论...
验证码 换一张
取 消