【求助】为什么不自动关闭进程?WIN初级程序!!
#include <windows.h>#include <stdio.h>
#include <Winuser.h>
#define WIN_MAIN_TOP 100
#define WIN_MAIN_LEFT 100
#define WIN_MAIN_WIDTH 500
#define WIN_MAIN_HEIGHT 500
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam) ;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShowCmd)
{
HWND hWnd ;
WNDCLASSEX winClass ;
static TCHAR winName[] = TEXT("母体") ;
MSG msg ;
winClass.cbClsExtra = 0 ;
winClass.cbWndExtra = 0 ;
winClass.cbSize = sizeof(WNDCLASSEX) ;
winClass.hbrBackground = (HBRUSH)GetStockObject(1) ;
winClass.hCursor = LoadCursor(NULL, IDI_WINLOGO) ;
winClass.hIcon = LoadIcon(NULL, IDC_ARROW) ;
winClass.hInstance = hInst ;
winClass.lpfnWndProc = WndProc ;
winClass.lpszClassName = winName ;
winClass.lpszMenuName = NULL ;
winClass.style = CS_HREDRAW | CS_VREDRAW ;
winClass.hIconSm = LoadCursor(NULL, IDI_WINLOGO) ;
RegisterClassEx(&winClass) ;
hWnd = CreateWindowEx(WS_EX_ACCEPTFILES,
winName,
winName,
WS_OVERLAPPEDWINDOW,
WIN_MAIN_TOP, WIN_MAIN_LEFT,
WIN_MAIN_WIDTH, WIN_MAIN_HEIGHT,
NULL, NULL,
hInst,
NULL) ;
if(!hWnd)
{
MessageBox(NULL, "窗口无法注册", "错误信息", MB_OK) ;
return 0 ;
}
ShowWindow(hWnd, nShowCmd) ;
UpdateWindow(hWnd) ;
while(GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc ;
switch(lParam)
{
case WM_CREATE:
return 0 ;
case WM_PAINT:
return 0 ;
case WM_DESTROY:
DestroyWindow(hWnd) ;
return 0 ;
case WM_QUIT:
PostQuitMessage(0) ;
return 0 ;
default : ;
}
return DefWindowProc(hWnd, message, wParam, lParam) ;
}