The window keeps closing right away. Please tell me what I'm doing wrong. The following is a condensed version of the source for it.
Code:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS WndClass;
WndClass.style = 0;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.lpfnWndProc = WndProc;
WndClass.hInstance = hInstance;
WndClass.hbrBackground = (HBRUSH) (COLOR_MENU+1);
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
WndClass.lpszMenuName = 0;
WndClass.lpszClassName = "WinProg";
RegisterClass(&WndClass);
HWND hWindow;
hWindow = CreateWindow("WinProg","Test Windowl",
WS_OVERLAPPEDWINDOW,
0,0,600,500,NULL,NULL,
hInstance, NULL);
ShowWindow (hWindow, nCmdShow);
UpdateWindow (hWindow);
MSG Message;
while (GetMessage(&Message, NULL, 0, 0));
{
DispatchMessage(&Message);
}
return (Message.wParam);
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMessage,
WPARAM wParam, LPARAM lParam)
{
switch(uiMessage)
{
case WM_PAINT:
//some GDI functions
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
default:
return DefWindowProc (hWnd, uiMessage,
wParam, lParam);
}
}