Advertisement

Please take a look at this code

Started by May 22, 2002 09:29 AM
4 comments, last by mx1 22 years, 7 months ago
#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <windowsx.h> int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { MessageBox(NULL, "HELLO WORLD", MB_OK MB_ICONEXCLAMATION); return(0); } I get one error trying to compile it. Anyone know why?
your call to MessageBox is screwed up, look at the API docs, you''re missing the window title and there should be a | between the two MB_ parameters.

MessageBox(NULL, "hello world", "hello world", MB_OK | MB_ICONEXCLAMATION);

rtry that, it should work
Advertisement
Isn''t there anything missing between MB_OK and
MB_ICONEXCLAMATION ?

Try "+" or "|" ... or try just MB_OK...

And post the error string and code.

[Hugo Ferreira][Positronic Dreams][]
"Somewhere, something incredible is waiting to be known."
- Carl Edward Sagan (1934 - 1996)

Ok thanks a bunch.
Cool, it works now.
Sorry I am new to the Windows API and I just changed it to exactly how it shows in the book and it works.

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <windowsx.h>

int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
MessageBox(NULL, "THERE CAN BE ONLY ONE!!!",
"MY FIRST WINDOWS PROGRAM",
MB_OK | MB_ICONEXCLAMATION);
return(0);
}


That''s how it shows it in TOTWGPG and it works.
Thanks again.

you would want to create a window and a message handler.. otherwise you would be limited to programs which does one thing fast and then terminate.. if you put a loop in your current WinMain you would screw windows :-).. this is a good tutorial for creating a basic windows program:

http://www.peroxide.dk/download/tutorials/tut9/pxdtut9.htm

This topic is closed to new replies.

Advertisement