Here is a function to use in WM_PAINT

Code:
void   RePaint(HWND hDlg,HDC hdcScreen)
{
RECT                  Rect;
PAINTSTRUCT           ps;

GetUpdateRect(hWnd, &Rect, 0);
if (IsRectEmpty(&Rect))
   {
   GetClientRect(hWnd,&Rect);
   }
BeginPaint(hWnd, &ps);
BitBlt(ps.hdc, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, hdcScreen, Rect.left, Rect.top, SRCCOPY);
EndPaint(hWnd, &ps);
}
I have another HDC, exactly the same as the hdcScreen called hdcBuffer.
All drawing is done to the hdcBuffer. When it is ready it is BitBlt'ed to the hdcScreen. The area draw is known and this is sent for painting using InvalidateRect(), calling the paint function above.
I keep the HWND, HDC's(screen and Buffer) ect in an array of structures. I use defined values to navigate thru the array. I set the initial values to NULL. I set them up in WM_CREATE for the dlg as needed and then check on close if they have been allocated and so free the resources.