c++窗口创造了,窗口关闭,进程仍在

c++窗口创建了,窗口关闭,进程仍在!

为什么窗口关闭了,在进程里面关掉! 求解!大神help!
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinMyProc(
HWND hwnd, // handle to window
UINT uMsg,      // message identifier
WPARAM wParam,  // first message parameter
LPARAM lParam   // second message parameter
);

int WINAPI WinMain(
HINSTANCE hInstance,  // handle to current instance
HINSTANCE hPrevInstance,  // handle to previous instance
LPSTR lpCmdLine,      // pointer to command line
int nCmdShow          // show state of window
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_PEN);//BLACK_BRUSH
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);//IDC_CROSS
wndclass.hIcon=LoadIcon(NULL,IDI_INFORMATION);//IDI_ERROR 
wndclass.hInstance=hInstance;//当前实例的句柄
wndclass.lpfnWndProc=WinMyProc;//窗口过程函数
wndclass.lpszClassName="MyWindow";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW | CS_VREDRAW;

RegisterClass(&wndclass);//注册窗口类

HWND hwnd;
hwnd=CreateWindow(//创建窗口
"MyWindow",
"win32窗口程序!",
WS_OVERLAPPEDWINDOW,
500,//水平位置 CW_USEDEFAULT
300,//垂直位置
400,//窗口宽度
300,//窗口高度
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinMyProc(
HWND hwnd,      // handle to window
UINT uMsg,      // message identifier
WPARAM wParam,  // first message parameter
LPARAM lParam   // second message parameter
)
{
switch(uMsg){
case WM_CHAR:
char szchar[20];
sprintf(szchar,"Char is %d",wParam);
MessageBox(hwnd,szchar,"MyWindow",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"鼠标点击了","MyWindow",MB_OK);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"...我的win32窗口程序!",strlen("...我的win32窗口程序!"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"我的win32窗口程序!",strlen("我的win32窗口程序!"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否关闭窗口?","MyWindow",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

------解决方案--------------------
 while(GetMessage(&msg,hwnd,0,0))
-->
    while(GetMessage(&msg,NULL,0,0))