15,979
社区成员
发帖
与我相关
我的任务
分享
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
InflateRect(&rt,-20,-20);
BitBlt(hdc,rt.left,rt.top,rt.right-rt.left,rt.bottom-rt.top,hdc,0,0,BLACKNESS);
EndPaint(hWnd, &ps);
break;
效果是在窗口中间显示一个黑框,编译后调整窗口大小时画面闪烁,这是正常的。把窗口类型的CS_HREDRAW | CS_VREDRAW取消掉,即把ATOM MyRegisterClass(HINSTANCE hInstance)函数里改成case WM_SIZE:
InvalidateRect(hWnd,NULL,FALSE);
return DefWindowProc(hWnd, message, wParam, lParam);