Okay, I just walked myself through a tut and I got the code down line by line. Actually wrote it out, and I'm pretty sure I understand everything that is going on at this point, but the thing is the window never actually shows!
Code:
#include <windows.h>
const char ClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
char* lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hWnd;
MSG Msg;
// Register the class!
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = ClassName;
wc.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Create the window!
hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, ClassName, "Window Title",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,240,120,
NULL, NULL, hInstance, NULL);
if(hWnd = NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// Start the message loop
while(GetMessage(&Msg, hWnd, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Am I doing something wrong?