INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE prevInst, LPSTR nCmdLine, int nCmdShow)
{
MSG msg;
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"Pong", NULL };
RegisterClassEx(&wc);
// Create the application''s window
HWND hWnd = CreateWindow( "Pong", "Pong Game",
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
// Initialize Direct3D
if(SUCCEEDED(Init(hWnd)))
{
try {
// Show the window
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// Enter the message loop
while(running) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
render();
}
}
} catch (HRESULT) {
DestroyWindow(hWnd);
}
}
// Clean up everything and exit the app
Cleanup();
UnregisterClass( "Pong", wc.hInstance );
return (int) msg.wParam;
}
Runtime error -- msg undefined
I''m getting a Run-time error that says "Run-time Error Check #3 the variable ''msg'' is used without being defined"
here''s my winmain, it says it coming from my return line:
anything obvious that I''m missing? thx for any help
**Joshua
If
Init
fails, then you''ll never have used msg
, so you''d be returning an undefined variable. You should be able to put an else
on the end to return something else... If I had my way, I''d have all of you shot! codeka.com - Just click it.
Thanks for the speedy response, I took a look at my init and sure enough one of the files I was opening was misspelled. All that time looking in the wrong places and changing things that were fine, and it was one lousy letter... Well, I feel pretty dumb, but I least I learned something! Thanks again.
Now I can get back to debugging the rest of the game!
**Joshua
Now I can get back to debugging the rest of the game!
**Joshua
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement