Jump to content
  • Advertisement
Sign in to follow this  
Tera_Dragon

Odd casting error

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

I have just tried to compile some windows window creation code in a new project, but some lines of code are giving me errors:
MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
error C2664: 'MessageBoxW' : cannot convert parameter 3 from 'const char [6]' to 'LPCWSTR' This is confusing me as in my other project this same code was working. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
I can't get _T() to work (error C3861: '_T': identifier not found).
And can't find how to change the project settings to use ANSI.

I've got it to compile by casting to (LPCWSTR), but this makes my text come out as chinese...

Share this post


Link to post
Share on other sites
To get the _T() macro to work you need to include tchar.h. Alternately you can try prefixing your strings with L. ex: L"Error" to make them wide strings.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tera_Dragon
How can I change the project settings to use ANSI with MSVS2005 beta?


Make sure _UNICODE isn't defined.

It's better to use _T() though as it'll work whether _UNICODE is defined or not.

See this link for more info.

Share this post


Link to post
Share on other sites
Thanks for the reply. Though I am now getting the error "error C2065: 'LstrFrameRate' : undeclared identifier" for the line
SetWindowText(g_hWnd, _T(strFrameRate));

Share this post


Link to post
Share on other sites
The _T() macro only works around string literals. Like _T("Moo"). If you want to define a character array you need to either use the TCHAR type or wchar_t instead of char.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!