哪位大哥帮我看一下下面的程序为什么不能正常显示窗口啊?(从任务管理器里面可以看到程序运行了的,就是不见窗口):
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK zgzproc(
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 zgzclass;
zgzclass.cbClsExtra=0;
zgzclass.cbWndExtra=0;
zgzclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
zgzclass.hCursor=LoadCursor(NULL,IDC_ARROW);
zgzclass.hIcon=LoadIcon(NULL,IDI_ERROR);
zgzclass.hInstance=hInstance;
zgzclass.lpfnWndProc=zgzproc;
zgzclass.lpszClassName="zgz";
zgzclass.lpszMenuName=NULL;
zgzclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&zgzclass);
HWND hwnd;
hwnd=CreateWindow
("zgzclass","zgz",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK zgzproc(
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 zgzchar[20];
sprintf(zgzchar,"The char is %d",wParam);
MessageBox(hwnd,zgzchar,"zgz",MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"Mouse Clicked!","zgz",MB_OK);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"你好!",strlen("你好!"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC zdc;
PAINTSTRUCT ps;
zdc=BeginPaint(hwnd,&ps);
TextOut(zdc,0,0,"太高兴了",strlen("太高兴了"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"确定退出吗?","zgz",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}