Hi,

I have a problem whereby when i moved a square on a
picture(bitmap)based on a button pressed, it will increase the
coordinates of the square and redraw but i'm unable to clear the old
coordinates square, making the whole picture full of squares. Below is
my code.. could anyone help me to solve the problem. Thanks in
advanced... need to solve it urgently:

void CSA2004View::OnDraw(CDC* pDC)
{
CSA2004Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

HBITMAP hBmp,Defbmp;
CDC dcMem;
CDC cpydc;

// a picture that get from pDoc.
hBmp = pDoc->GetBitmap();
Defbmp = pDoc->GetBitmap();
if(hBmp)
{
CPoint pt,l1,l2,l3,l4;
CRect rcClient;

GetClientRect(&rcClient);
pt = GetScrollPosition();

dcMem.CreateCompatibleDC(pDC);
cpydc.CreateCompatibleDC(pDC);

//when a button press, it will enable
(boolean)GetUpdateXY(),
//and increase the XY coordinates.
if( pDoc->GetUpdateXY())
{
cpydc.SelectObject(Defbmp);
pDC->StretchBlt(rcClient.left, rcClient.top,
rcClient.right, rcClient.bottom,
&cpydc,
pDoc->ScaleScreen(pt.x),
pDoc->ScaleScreen(pt.y),
pDoc->ScaleScreen(rcClient.right),
pDoc->ScaleScreen(rcClient.bottom),
SRCCOPY);
InvalidateRect(NULL);
//Disable the (boolean)GetUpdateXY()
pDoc->DisableUpdateXY();

}
else
{
dcMem.SelectObject(hBmp);
pDC->StretchBlt(rcClient.left, rcClient.top,
rcClient.right, rcClient.bottom,
&dcMem,
pDoc->ScaleScreen(pt.x),
pDoc->ScaleScreen(pt.y),
pDoc->ScaleScreen(rcClient.right),
pDoc->ScaleScreen(rcClient.bottom),
SRCCOPY);

}


// Create a Pen
CPen penBlue(PS_SOLID,1,RGB(0,0,255));
CPen *pOldPen1 = NULL;
pOldPen1 =dcMem.SelectObject(&penBlue);


// Draw a square
dcMem.MoveTo(pDoc->GetX(),pDoc->GetY());
dcMem.LineTo(pDoc->GetX(),pDoc->GetY()+50);
dcMem.LineTo(pDoc->GetX()+50,pDoc->GetY()+50);
dcMem.LineTo(pDoc->GetX()+50,pDoc->GetY());
dcMem.LineTo(pDoc->GetX(),pDoc->GetY());

// Reselect the old pen
dcMem.SelectObject(pOldPen1);

} //End of IF statement

}