Sign in to follow this  

Window caption displaying incorrectly

This topic is 4251 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

The caption of my application window doesn't show correctly. I'm using "(LPCWSTR)strCaption" to set it. I've also tried using "(LPCWSTR)&strCaption" but it doesn't work either. I get errors from the compiler if I don't convert the string to LPCWSTRs saying "error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [256]' to 'LPCWSTR'". The caption shows correctly, however, if I use L"My Window Caption" but that way I can't store the string. I have set the compiler to use the unicode character set, maybe this has something to do with it? Juha

Share this post


Link to post
Share on other sites
Yes putting L in front of a string makes it unciode. To store a unicode string, use:

wchatr_t str[256];

This uses unicode (or 'wide') character for your string.

Hope that helps!

Share this post


Link to post
Share on other sites
Yes. Unicode uses wchar_t* strings, multi-byte uses char* strings. You need to convert your multi-byte string to a wide char string with the MultiByteToWideChar function (MSDN search seems to be down just now so I can't link it). The other alternative is to read it in from wherever you're getting it as a wchar_t*, or store it as a wchar_t* (Using L"Window Titile", as you do).

Share this post


Link to post
Share on other sites

This topic is 4251 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