// 2.cpp : Defines the entry point for the application.
//#include "stdafx.h"
//function=prototype
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
WNDCLASS wc;
MSG msg;
wc.style =CS_VREDRAW |CS_HREDRAW;
wc.lpfnWndProc =WndProc;
wc.cbClsExtra =wc.cbWndExtra =0;
wc.hInstance =hInstance;
wc.hIcon =NULL;
wc.hCursor =NULL;
wc.lpszMenuName =NULL;
wc.hbrBackground =NULL;
wc.lpszClassName ="demo"; HWND hWnd;
hWnd=::CreateWindow("demo","demo",WS_OVERLAPPEDWINDOW,0,0,50,50,NULL,NULL,hInstance,NULL);
if (hWnd==NULL)
{


return FALSE;
} ::RegisterClass(&wc);
::ShowWindow(hWnd,nCmdShow);
::UpdateWindow(hWnd); while(TRUE)
{
if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if (::GetMessage(&msg,NULL,0,0)==0) return (int)msg.wParam;
TranslateMessage(&msg);
            DispatchMessage(&msg);

}
else
::WaitMessage();

}


  return 0;
}LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_KEYDOWN:
::PostMessage(hWnd,WM_CLOSE,0,0);
return 0L;
case WM_DESTROY:
::PostQuitMessage(0);
return 0L;
}
return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}