Jump to content
  • Advertisement
Sign in to follow this  
adam17

NeHe base code and VC++ 2005

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement


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 this post


Link to post
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 this post


Link to post
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!