0

MessageBox(NULL, (LPCTSTR)"Test1", (LPCTSTR)"Test1", MB_OK);

This code is popping up the window correctly, but it displays all squares. Whats wrong =(

Edited by clutchkiller: n/a

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by Salem
0

Im just using VC++ express 2008. All default settings so I couldnt tell ya

Then that's probably the problem -- turn UNICODE off! To do that go to menu item Project --> Properties (the last item on that menu) --> Configuration Properties --> General. Then on the right side of the screen change Character Set (third from the bottom) to Not Set Also remove those unnecessary typecasts.

0

> MessageBox(NULL, (LPCTSTR)"Test1", (LPCTSTR)"Test1", MB_OK);
Indiscriminate casting to get the compiler to STFU is a common problem.

Just because you muffled the compiler doesn't make your code good.

Take out the casts, then pay really close attention to the error messages.
http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

lawl.

Thanks dragon

0

Then that's probably the problem -- turn UNICODE off! To do that go to menu item Project --> Properties (the last item on that menu) --> Configuration Properties --> General. Then on the right side of the screen change Character Set (third from the bottom) to Not Set Also remove those unnecessary typecasts.

There's something I don't understand: Why should UNICODE be off? It does contain more characters than ASCII doesn't it? What displays those characters if UNICODE doesn't?

1

Well it would display a UNICODE string, were a UNICODE string actually passed as a parameter.

> (LPCTSTR)"Test1"
Would be stored in memory as 54 65 73 74 31 00
Now whilst 0x6554 is in the UNICODE space, it isn't going to be anything resembling Latin text.

Now saying L"Test1" would result in 54 00 65 00 73 00 74 00 31 00 00 00
These too are valid UNICODE characters, but 0x0054 is going to display a 'T' for you.

Better still (which seems to have been lost altogether by the OP) would be to say _TEXT("Test1") Then no matter how much you mess with the "turn it on or turn it off options" in the compiler, it will do "the right thing".

Further, if the OP has any ambitions of a career, then knowing about UNICODE is pretty much a given (well knowing more than how to turn it off at any rate).

Votes + Comments
thnx :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.