MFC or pure Win32?
For MFC you need to override the OnPaint() and create a memory DC along with a memory CBitmap.
Code:
void SomeWindow::OnPaint(void)
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CRect rect;
GetClientRect(&rect);
CBitmap memBitmap;
memBitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
CBitmap *pPrevBitmap=memDC.SelectObject(&memBitmap);
//Draw to memDC now
....
....
//Blit final result to dc
dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memDC.SelectObject(pPrevBitmap);
}
This is the equivalent of double buffering in MFC code. Check the code because the SelectObject's don't look quite right. If you leak GDI objects here, those lines are the culprit.