Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

"Hello World" in Visual Studio 2005 win32

appapp Member Posts: 2
I'm trying to follow a win32 tutorial at http://www.winprog.org/tutorial/

I'm working in Visual Studio 2005 c++. I create a new project under the win32 option and select the "win32 project" template. Then under "application settings" I select "windows application" and check the "empty project" check box. Then under project/add new item, I add a c++ source file. To this source file, I paste the following code:

#include

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
return 0;
}

This will not run at all unless I change the suffix of the name of the source file from .c++ to .c. Then it will open a window(yippee!- this alone felt like a major accomplishment) but doesn't display the text, only small rectangles where it looks like the text should be.

The debug log lists a bunch of .dll files, each followed by "No symbols loaded."

Some questions:

How can I make this code run in my IDE- changes to the code, settings in MSVS, etc? or can I? I realize this might be more of an IDE problem than win32, but I figure there are more people here that know MSVS than there are people in the visual forum who know win32.

My recent experience is limited to successfully working through several online c++ tutorials using console program examples and I have recently purchased Petzold's "Programming Windows." I also programmed fairly extensively in BASIC and FORTRAN back in the commodore 64 days, and during my undergrad work in physics.

Comments

  • DonotaloDonotalo Member Posts: 715
    [purple]click project, then select your project properties. from the left pane, select Configuration Properties->General. from the right pane, u will see under Project Defaults, "Character Set" is set as "Use Unicode Character Set." Set it to "Not Set." now ur program should display correct text.

    instead of doing these, u can also use MessageBoxA() for displaying C String. Remember, LPCSTR is a long pointer to c string and LPWSTR is a long pointer to wide character string.

    why r u using .c++ as a c++ source code file extension? it is .cpp, not .c++. try with .cpp file extension.

    microsoft changes some default options to their own choice, like by default MessageBox() will call MessageBoxW() which uses wide character set. so hunt project properties for ur own preferences.
    [/purple]
    [hr][purple]~Donotalo()[/purple]
  • appapp Member Posts: 2
    That did it. Thanks!

    I didn't name the file .c++, it defaults to .cpp, the .c++ was just a typo.
Sign In or Register to comment.