NeHe base code and VC++ 2005

This topic is 4924 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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?

Share on other sites

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

Share on other sites
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?

Share on other sites
You don't need the typecasts.

Share on other sites
i went back and removed all of those typecasts and they worked! appreciate guys and girls (if they even view this forum lol)

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• Forum Statistics

• Total Topics
634047
• Total Posts
3015232
×