Advertisement

NeHe base code and VC++ 2005

Started by July 23, 2005 11:15 AM
3 comments, last by adam17 19 years, 1 month ago
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:
MessageBox(NULL, (LPWSTR)"this is a message box", (LPWSTR)"this is the title", MB_OK|MB_ICONEXCLAMATION);
any ideas on what is going on?


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
Advertisement
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?
You don't need the typecasts.
i went back and removed all of those typecasts and they worked! appreciate guys and girls (if they even view this forum lol)

This topic is closed to new replies.

Advertisement