Jump to content
  • Advertisement
Sign in to follow this  
Symphonic

Unicode in MessageBoxW

This topic is 3715 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'm trying to do localization stuff, I pull a unicode string (currently in Russian) out of a file, and I try to do something with it:
const wchar_t * theString = TextManager.Get("ERROR_MSG");

MessageBoxW(gHWND, theString, theString, MB_OK);
The message box that comes up has a series of boxes in it (signifying unrecognized characters). I have russian installed on my machine, and I can type in russian into the text database files. The strings will display in-game with the text-renderer, and if I copy-paste the hex into a word document it displays correctly. Sadly I need this to work outside the renderer because the message may be 'We could not create the renderer' (equivalent). I suspect I'm missing something obvious.

Share this post


Link to post
Share on other sites
Advertisement
That strikes me as very likely, I assume that on a target machine which is actually operating in russian, I can expect that the Cyrillic character set would be present.

Any idea how I can install the extra characters on my local machine as a sanity check?

Share this post


Link to post
Share on other sites
If you have Russian installed as one of the Regional and Language Options, and not just a Russian Font, it should just work if you're using unicode.

The only other thing I can think of is if you didn't actually save the actual C++ file in a Unicode format. Or, if you don't have the actual program supporting Unicode. That would pretty much revert to ASCII, causing the boxes.

I'd suggest keeping with MessageBox, rather than using MessageBoxW, as it should wrap the correct function according to the character set supported by your program.

Share this post


Link to post
Share on other sites
As Nytegard said you shouldn't need to use MessageBoxW() you should just use MessageBox() and with _UNICODE and UNICODE preprocessor defines it will chose the correct one. That also ensures your program is unicode.

Share this post


Link to post
Share on other sites
But he's using wchar_t rather than TCHAR.

If you want to be able to toggle Unicode on and off, you're right, he should use MessageBox() (and TCHAR).
But if he just wants to use Unicode, period, he might as well be explicit about it, and use wchar_t (as he does) and MessageBoxW().

Share this post


Link to post
Share on other sites
It looks like your using c++. With the MessageBox function I have always seen it set to NULL, I guess you could probably using zero(0) too. I'm talking about the first parameter of MessageBox, so something like this

MessageBox(NULL, theString, theString, MB_OK);




I think the NULL is used to represent the desktop window.

Share this post


Link to post
Share on other sites
Quote:
Original post by boolean010
I think the NULL is used to represent the desktop window.


Coincidentally, yes. From winuser.h:

#define HWND_DESKTOP ((HWND)0)

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!