Advertisement

What's Wrong here?

Started by August 22, 2001 07:54 PM
5 comments, last by Sage13 23 years, 6 months ago
Hey, I''m using this block of code from a game programing book as an example in Visuall C++ 6.0. everytime I try to compile it it says " Cannot execute program " What am I missing here? ( Note, I took out the <> so you could see the code, so besides those) // PROG3_2.CPP - A simple message box #define WIN32_LEAN_AND_MEAN #include windows.h #include windowsx.h // main entry point for all windows programs int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { // call message box api MessageBox(NULL, "What''s up world!", "My First Windows Program",MB_OK); // exit program return(0); } // end WinMain
Its not ncmdshow, it is int nShowCmd

lol. Good luck.



"I''''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''''Urden
------------------------------Put THAT in your smoke and pipe it
Advertisement
what project settings did you use ??

it looks like your visual C++ settings cannot find your exe file.

btw, nCmdShow does mean anything if you dont make a window or show it.


check your project settings. Try to double click the exe and see what happens.



{ Stating the obvious never helped any situation !! }
Is that all it said was "Cannot execute program"? If so, then yeah, give us your project settings.

quote:
( Note, I took out the <> so you could see the code, so besides those)


If you want to use < and > in your post, just type &lt; and &gt;.

quote:
Its not ncmdshow, it is int nShowCmd


The compiler could care less, just so long as it is of type int.
Thanx, actually, it was my project settings. It wasn''t set up right, I got it working now, but I''ve hit another spot.

In creating the classes for Windows, where dose this part go in the program:

typedef struct _WNDCLASS
{

UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;

} WNDCLASS;

WNDCLASS wndclass;



and where dose all of this information about the things in the structure go? :


wndclass.style = CS_DBLCKS | CD_OWNDC |
CS_HREDRAW | CS_VREDRAW;

wndclass.lpfnWndProc = WindowProc;


wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;

wndclass.hInstance = hinstance;

wndclass.hIcon =LoadIcon(NULL, IDI_APPLICATION);

wndclass.hCursor = LoadCursor =(NULL, IDC_ARROW);

wndclass.hbrBackground= (HBRUSH)GetStockObject(BLACK_BRUSH);

wndclass.lpszMenuName= NULL;

wndclass.lpszClassName = "WINCLASS1";



thanx again.

-Sage13
You dont have to actually declare the wndclass struct because its already defined. You fill out the wndclass struct pretty much right after WinMain():

int WINAPI WinMain(HINSTANCE hinstance,                   HINSTANCE hprevinstance,                   LPSTR lpcmdline,                   int ncmdshow){    MSG msg;    WNDCLASSEX wcex;    wcex.cbSize = sizeof(WNDCLASSEX);     wcex.style			= CS_HREDRAW | CS_VREDRAW;    wcex.lpfnWndProc	= (WNDPROC)WndProc;    wcex.cbClsExtra		= 0;    wcex.cbWndExtra		= 0;    wcex.hInstance		= hInstance;    wcex.hIcon			= LoadIcon(hInstance,                                           (LPCTSTR)IDI_MY2);    wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);    wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);    wcex.lpszMenuName	= (LPCSTR)IDC_MY2;    wcex.lpszClassName	= szWindowClass;    wcex.hIconSm		= LoadIcon(wcex.hInstance,                                           (LPCTSTR)IDI_SMALL);    RegisterClassEx(&wcex);//Create window//update window//show window//Main message loop  

Of course it doesnt have to go right here it just has to go before you create the window etc.

Hope this helps


Edited by - Zeke on August 23, 2001 5:18:35 AM
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Advertisement
Ok, thanx!

-Sage13

This topic is closed to new replies.

Advertisement