// JP opened flex table

Click to See Complete Forum and Search --> : mouse moveing redraw problem


David_chen
November 21st, 2001, 05:18 PM
Thanks in advance,
I meet a problem when redraw rectangle as moving mouse.

OnMouseMove(UINT nFlags, CPoint point)
{
CClientDC dc(this);
//check the mouse whether or not in the rect of seed
if(m_seedSelected==TRUE)
{
//Get the seed from the CDoement
CSeed * pseed=pDoc->GetSeed();
//Get seed's referenc position
CPoint pt=pseed->GetPosStart();//it is Logical coordinate
//InvalidateRect the oldRect and new Rect
CRect oldRect, newRect;
oldRect.left=pt.x;
oldRect.top=pt.y;
oldRect.right=pt.x+pseed->Width();
oldRect.bottom=pt.y+pseed->Height();
OnPrepareDC(&pc);
dc.LPtoDP(oldRect);//change to Device coordinate
InvalidateRect(oldRect, TRUE);

OnPrepareDC(&dc);
dc->DPtoLP(&point)//change the point coordinate
pseed->SetPosition(point);//seed new position
pDoc->SetModifiedFlag(TRUE);//save the change to doc
newRect.left=point.x;
newRect.top=point.y;
newRect.right=point.x+pseed->Width();
newRect.bottom=point.y+pseed->Height();
OnPrepareDC(&dc);
dc.LPtoDC(&newRect); //change the coordinate
InvalidateRect(newRect, TRUE);
}
}
This question is that: the InvalidateRect could not erase the trace of the seed, as I am moving the mouse quickly I observed the newRect is exactly at the mouse point, the secondly is the oldRect which is a little late the newRect, the amased thing is the seed redrawing is the lastest action and not exactly at the position of mouse. so the InvalidateRect could not erase the trace of the seed.

I don't understand the reason, please help me! thanks!

//JP added flex table