CRect rcClient;
GetClientRect(&rcClient);
int cx = rcClient.Width();
int cy = rcClient.Height();
//Create Memory Device Context
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
//Draw BackGround
CBitmap bitmapBkGnd;;
bitmapBkGnd.CreateCompatibleBitmap(pDC, cx, cy);
CBitmap* pOldbitmapBkGnd = MemDC.SelectObject(&bitmapBkGnd);
//Draw Grid
DrawGrid(&MemDC);
//Draw Knots and Curve
if(AfxIsValidAddress(m_pCurve, sizeof(CObject)))
{
DrawCurve(&MemDC);
DrawKnots(&MemDC);
}
pDC->BitBlt (0, 0, cx, cy, &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(pOldbitmapBkGnd);
MemDC.DeleteDC();