if(hSourceBmp != NULL)
{
MemDC.CreateCompatibleDC(&dc);
OldBitmap=(HBITMAP)MemDC.SelectObject(hSourceBmp);
//dc.BitBlt(20,20,rect.Width()-20,rect.Height()-20,&MemDC,0,0,SRCCOPY);
//I counld not see the client rect value of your window.
//just test it.
dc.BitBlt(0,0,50,50,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(OldBitmap);
}
//Delete by youself
DeleteObject(hSourceBmp);
// you should delete MemDC here!
// Release dc here