MessageBox(NULL, (LPWSTR)"this is a message box", (LPWSTR)"this is the title", MB_OK|MB_ICONEXCLAMATION);
any ideas on what is going on?
NeHe base code and VC++ 2005
i just tried to port my code which is a derivative of NeHe's code into VC++ 2005. ive run into ALOT of problems with it. ive fixed enough where it compiles but it doesnt run. i get 4 message boxes and then it crashes. the problems is, i have no idea what the boxes are saying. all for of them show this:
[img=http://img182.imageshack.us/img182/8445/messageboxerror1rj.th.jpg]
i had to type cast all of the text that went into the MessageBox functions. for example:
Seems as if you're compiling a unicode version of the program. In this case, prefix your strings with an "L", e.g.
MessageBox(NULL, L"this is a message box", L"this is the title", MB_OK|MB_ICONEXCLAMATION);
Otherwise you will cast the pointer, but the content will be all wrong since Unicode (UTF-16) characters are 16 bit wide and yourt string olny contains 8 bit characters ("th" becomes one unicode character for example).
Solution: either prefix your string as shown above or change the project settings to use the "Multibyte Character Set".
HTH,
Pat
sweet! i changed the project settings to multibyte character set and changed the (LPWSTR) typecasts to (LPCSTR). it works now thankfully. is there a way to eliminate that completely or is that a part of the standard?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement