Jump to content
  • Advertisement
Sign in to follow this  
TexMurphy

Very basic windows programming

This topic is 4009 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

Hey, I've been following the tutorials for Windows programming at www.directxtutorial.com, but when I came to use the first example code, it wouldn't compile for me. The code is rather simple, it's just to create a 'hello world' message box. The function call is as follows: MessageBox(NULL, L"Hello World!", L"Just another Hello World program!", MB_ICONEXCLAMATION | MB_OK); It runs into a problem on that bottom line, where it says, "WinProgMain.cpp(12) : error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'const unsigned short [13]' to 'LPCSTR'." So, err... help a newbie out?

Share this post


Link to post
Share on other sites
Advertisement
That code assumes that you are compiling using unicode, which apparently you are not. You have a couple options:

1. Compile with unicode. You can either find the setting in your compiler and change it, or just put the following somewhere before you include windows.h:
#define UNICODE

2. Change the string literals from wide strings to normal ones. Remove the "L" prefix:

MessageBox(NULL,
"Hello World!",
"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);

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!