Sign in to follow this  

TEXT("my text") driving me nuts

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok there is some kinda setting in visual c++ 2008 that is forcing me to do this wndclass.lpszClassName = TEXT("Window Class"); when I should only have to do wndclass.lpszClassName = "Window Class"; and ideas? please help.

Share this post


Link to post
Share on other sites
Thats because your project is set to use Unicode as the character set. If you want avoid using TEXT() or L before string literals, go to the project properties and at the Configuration Properties->General, Character Set item, choose Use Multibyte Character Set. HTH

Share this post


Link to post
Share on other sites
Just so you understand what's going on here...

When your VC++ project is set to use Unicode as it's character set, it #define's UNICODE. Then when you #include the Windows API headers (windows.h and friends), those headers define a special character type called TCHAR. TCHAR is typedef'ed to either CHAR or WCHAR depending on whether UNICODE is defined, and Win32 functions and structures that take strings take strings of TCHAR's (LPTSTR or LPCTSR). So when you use the Unicode setting, you have to send them strings of WCHAR's. The TEXT() macro will take a string literal and output either a CHAR or WCHAR string literal depending on your Unicode settings, which is why it's working for you. You can also prefix a string literal with "L" to specify a WCHAR string.

Share this post


Link to post
Share on other sites

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this