#include <windows.h>
#define szWindowClass "MyWClass";
ATOM MyRegisterClass(HINSTANCE);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK MainProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
MSG msg;
MyRegisterClass(hInstance);
InitInstance(hInstance, nShowCmd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wce;
wce.cbSize = sizeof(wce);
wce.style = CS_HREDRAW|CS_VREDRAW;
wce.lpfnWndProc = MainProc;
wce.cbClsExtra = 0;
wce.cbWndExtra = 0;
wce.hInstance = hInstance;
wce.hIcon = NULL;
wce.hCursor = LoadCursor(NULL, IDC_ARROW);
wce.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wce.lpszMenuName = NULL;
wce.lpszClassName = szWindowClass;
wce.hIconSm = NULL;
return RegisterClassEx(&wce);
}
BOOL InitInstance(HINSTANCE hInstance, int nShowCmd)
{
HWND hWnd;
hWnd = CreateWindow(
"MyWClass",
"cocoDialog",
WS_SYSMENU,
150,
150,
800,
600,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hWnd, nShowCmd);
UpdateWindow(hWnd);
return TRUE;
}
LRESULT CALLBACK MainProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
default :
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}