Here the Painting the Window mentioned that:
After you finish painting the client area, you clear the update region, which tells the operating system that it does not need to send another WM_PAINT message until something changes.
One may write these code:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
RECT rect;
GetClientRect(hWnd, &rect);
HBRUSH brush = CreateSolidBrush(RGB(127, 127, 127));
FillRect(hdc, &rect, brush);
const wchar_t * lstr = L"here is information";
TextOut(hdc,
5, 5,
lstr, _tcslen(lstr));
DrawText(hdc, TEXT("Singleline in center~"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
MoveToEx(hdc, 50, 100, NULL);
LineTo(hdc, 44, 10);
LineTo(hdc, 78, 40);
Rectangle(hdc, 16, 36, 72, 70);
Rectangle(hdc, 34, 50, 54, 70);
DeleteObject(brush);
EndPaint(hWnd, &ps);
}
What means by clear here? We do not want what we have drawn to be cleared.