我所描绘的图像为什么会抖
#include <windows.h>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
TCHAR lpszTitle[]=TEXT("MyDemo3");
wndclass.style =CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("MyClass");
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
if(!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("RegisterClass fail!"), TEXT("error"), MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(
TEXT("MyClass"),
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
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 iParam)
{
HDC hdc;
hdc=GetDC(Hwnd);
HPEN hPen,hhPen,hhhPen;
hPen = CreatePen(PS_SOLID ,10,RGB(124,252,0));
hhPen=CreatePen(PS_SOLID ,10,RGB(250,128,114));
hhhPen=CreatePen(PS_SOLID ,5,RGB(0,0,0));
HBRUSH hBrush=CreateSolidBrush(RGB(34,139,34));
HBRUSH hhBrush=CreateSolidBrush(RGB(255,69,0));
switch(message)
{
case WM_PAINT:
hBrush=(HBRUSH)SelectObject(hdc,hBrush);
hPen=(HPEN)SelectObject(hdc,hPen);
RoundRect(hdc,1,1,100,600,1,20);
hhBrush=(HBRUSH)SelectObject(hdc, hhBrush);
hhPen=(HPEN)SelectObject(hdc,hhPen);
RoundRect(hdc,800,1,300,600,1,20);
hhhPen=(HPEN)SelectObject(hdc,hhhPen);
MoveToEx(hdc,300,0,NULL);
LineTo(hdc,800,0);
MoveToEx(hdc,300,100,NULL);
LineTo(hdc,800,100);
MoveToEx(hdc,300,200,NULL);
LineTo(hdc,800,200);
MoveToEx(hdc,300,300,NULL);
LineTo(hdc,800,300);
MoveToEx(hdc,300,400,NULL);
LineTo(hdc,800,400);
MoveToEx(hdc,300,500,NULL);
LineTo(hdc,800,500);
MoveToEx(hdc,300,600,NULL);
LineTo(hdc,800,600);
MoveToEx(hdc,300,0,NULL);
LineTo(hdc,300,600);
MoveToEx(hdc,400,0,NULL);
LineTo(hdc,400,600);
MoveToEx(hdc,500,0,NULL);
LineTo(hdc,500,600);
MoveToEx(hdc,600,0,NULL);
LineTo(hdc,600,600);
MoveToEx(hdc,700,0,NULL);
LineTo(hdc,700,600);
MoveToEx(hdc,800,0,NULL);
LineTo(hdc,800,600);
SelectObject(hdc,hPen);
DeleteObject(hPen);
SelectObject(hdc,hhPen);
DeleteObject(hhPen);
SelectObject(hdc,hhhPen);
DeleteObject(hhhPen);
SelectObject(hdc,hBrush);
DeleteObject(hBrush);
SelectObject(hdc,hhBrush);
DeleteObject(hhBrush);
ReleaseDC(Hwnd,hdc);
return 0;
case WM_LBUTTONDOWN:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(Hwnd, message, wParam, iParam);
}
请问什么会抖,而且最后有些图像会消失?(还有:那个让最大化会失效的代码wndclass.style =xxxx,那xxxx怎么写)