C++窗口代码
下面是我抄的书上的代码,编译都能通过,但执行没有结果。请高手帮忙解决一下!#include<windows.h>LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam){ HDC hdc; HBRUSH hbrush; HPEN hpen; PAINTSTRUCT ptstr; switch(iMessage) { case WM_PAINT: hdc=BeginPaint(hWnd,&ptstr); SetMapMode(hdc,MM_ANISOTROPIC); hpen=(HPEN)GetStockObject(BLACK_PEN); SelectObject(hdc,hpen); hbrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH); SelectObject(hdc,hbrush); RoundRect(hdc,50,50,100,150,15,15); hbrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH); SelectObject(hdc,hbrush); Pie(hdc,250,50,300,100,250,50,300,50); EndPaint(hWnd,&ptstr); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }}BOOL InitWindows(HINSTANCE hInstance,int nCmdShow){ HWND hwnd; hwnd=CreateWindow( "WinFill", "我的一个实例", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL,); if(!hwnd) return false; ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); return true;}BOOL InitWindowClass(HINSTANCE hInstance){ WNDCLASS wndclass; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH)); wndclass.hCursor=LoadIcon(NULL,"END"); wndclass.hInstance=hInstance; wndclass.lpfnWndProc=WndProc; wndclass.lpszClassName="WinFill"; wndclass.lpszMenuName=NULL; wndclass.style=CS_HREDRAW|CS_VREDRAW; return RegisterClass(&wndclass);}int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow){ MSG Message; if(!InitWindowClass(hInstance)) return false; if(!InitWindows(hInstance,nCmdShow)) return false; while(GetMessage(&Message,0,0,0)) { TranslateMessage(&Message); DispatchMessage(&Message); } return Message.wParam;}