vc编写的windows程序编译链接都没错误,但窗口不能输出,求高人解答
#include<windows.h>#include<stdlib.h>
#include<string.h>
int i=0;
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,long lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindowsClass(HINSTANCE hInstance,int nCmdShow);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindowsClass(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
long WINAPI 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);
if(0==i%3)
{
hBrush=(HBRUSH)CreateSolidBrush(RGB(255,0,0));
}
else if(1==i%3)
{
hBrush=(HBRUSH)CreateSolidBrush(RGB(0,255,0));
}
else
{
hBrush=(HBRUSH)CreateSolidBrush(RGB(0,0,255));
}
SelectObject(hDC,hBrush);
Rectangle(hDC,0,0,1000,550);
i++;
DeleteObject(hBrush);
EndPaint(hWnd,&PtStr);
Sleep(1000);
InvalidateRect(hWnd,NULL,1);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd,iMessage,wParam,lParam);
}
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName="WinFill";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
return RegisterClass(&wndclass);
}
BOOL InitWindowsClass(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow("颜色",
"颜色",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}