//这种情况下窗口背景是不发生变化的
case WM_PAINT:
{
HDC hDCMem;
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
hDCMem = CreateCompatibleDC(hdc);
RECT rcWnd = {};
GetClientRect(_this->m_hWnd, &rcWnd);
FillRect(hDCMem,&rcWnd,(HBRUSH)(GetStockObject(BLACK_BRUSH)));
int nWidth = rcWnd.right - rcWnd.left;
int nHeight = rcWnd.bottom - rcWnd.top;
BitBlt(hdc,0,0,nWidth,nHeight,hDCMem,0,0,SRCCOPY);
EndPaint(hWnd, &ps);
}
break;
//这种情况下窗口背景是正常的
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rcWnd = {};
GetClientRect(hWnd, &rcWnd);
FillRect(hdc,&rcWnd,(HBRUSH)(GetStockObject(BLACK_BRUSH)));
EndPaint(hWnd, &ps);
}
break;
------解决思路----------------------
CreateCompatibleDC得到的 DC 是空白的,必须要选择一个图形对象。