这个是一个能用的版本。。自己对照一下吧。。
#include
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd= NULL;
WNDCLASS wc;
MSG msg;
wc.cbClsExtra =0;
wc.cbWndExtra =0;
wc.hbrBackground =(HBRUSH)(COLOR_WINDOW);
wc.hCursor =LoadCursor(NULL, IDC_ARROW);
wc.hIcon =LoadIcon(NULL, IDI_WINLOGO);
wc.hInstance =hInstance;
wc.lpfnWndProc =(WNDPROC)WndProc;
wc.lpszClassName ="WndClass";
wc.lpszMenuName =NULL;
wc.style =0;
RegisterClass(&wc);
hWnd= CreateWindow("WndClass", "XX", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);//放在这里
}