Jump to content

A Win32 MessageBox Unicode question

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Smilex

Smilex

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
So I have this code
MessageBox(0, "First Win32 Program.", "Window Title", MB_OK);
And as the WinUser.h file says, that's just a typedef for either MessageBoxW or MessageBoxA, depending on if your project is set to use Unicode(It's MessageBoxW when it's unicode).
Now the sample code above does not compile when the project is set to use Unicode. That means that the code below will not run:
MessageBoxW(0, "First Win32 Program.", "Window Title", MB_OK);
But this next code does:
MessageBoxA(0, "First Win32 Program.", "Window Title", MB_OK);

The problem supposedly lies with the second parameter, "First Win32 Program.". Now the question I have is, how do I fix this problem if I want to continue using Unicode? And if possible, perhaps an explanation of why this does not work.

Thanks in advance.

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
According to this you can either put L in front of your text or use TEXT() macro to make it wide char.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
Smilex

Smilex

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
This is rage worthy. I knew that, I tried it and it didn't work. Now I did it again, and it works.
Then I rushed onto this topic to hopefully stop anyone from wasting time on this question, but unfortunately I was too late :/
Thanks for replying though.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users