App wont open
I'm using the tutorial from www.gametutorials.com to make a simple game, i started off just a plain window with a black background but when i compile it and run it, the window doesn't show up and after a while, i ended up copying almost the entire thing from the tutorial but the window still wouldn't show up. I'm new to win32 so the mistake is probably obvious.
HWND CreateMainWindow(HINSTANCE hInstance)
HWND hWnd = NULL;
memset(&wc, 0, sizeof(WNDCLASS));
wc.hInstance = hInstance;
wc.lpszClassName = "Game";
wc.lpfnWndProc = WinProc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.lpszMenuName = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
hWnd = CreateWindow("Game",
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
g_hInstance = hInstance;
every function here have been declared and defined
int WINAPI WinMain (HINSTANCE hThisInstance,
HWND hWnd = CreateMainWindow(hThisInstance);
if (hWnd == NULL) return false;
Also, if anyone has that tutorial, does MainLoop return a WPARAM? the return value isnt used anywhere so why not void?
I don't see anything necessarily wrong with that code. What do your init, MainLoop, and WinProc functions look like?
What's the code of your WndProc ? Chances are that it is your problem.
Maybe there is one "break" or "return" missing from a WndProc case label.
That has happened to me pretty often.
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, msg, lParam, wParam);
Oh, so i mixed up wparam with lparam...