关于深入浅出MFC里的问题不解,请火速帮忙?
pcwl 2002-04-02 05:20:57 第十一章:view功能的加强.......
在: 11.2 可滚动的窗口:CScroolView
void CScribbleView::OnUpdate(CView* /* pSender */, LPARAM /* lHint */,
CObject* pHint)
{
if (pHint != NULL)
{
if (pHint->IsKindOf(RUNTIME_CLASS(CStroke)))
{
// The hint is that a stroke as been added
//(or changed).
// So, invalidate its rectangle.
CStroke* pStroke = (CStroke*)pHint;
CClientDC dc(this);
OnPrepareDC(&dc);
CRect rectInvalid = pStroke->GetBoundingRect();
dc.LPtoDP(&rectInvalid);
InvalidateRect(&rectInvalid);//1.(这里是给窗口
//设无较区,以便重绘。
return;
}
}
// We can't interpret the hint, so assume that anything might
// have been updated.
Invalidate(TRUE);
return;
}
void CScribbleView::OnDraw(CDC* pDC)
{
CScribbleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// Get the invalidated rectangle of the view, or in the case
// of printing, the clipping region of the printer dc.
CRect rectClip;
CRect rectStroke;
pDC->GetClipBox(&rectClip);//2.(但这里得到的却是(0,0,0,0))
//这里得到本应该是“1”的无较区域是吗?
// Note: CScrollView::OnPaint() will have already adjusted the
// viewport origin before calling OnDraw(), to reflect the
// currently scrolled position.
// The view delegates the drawing of individual strokes to
// CStroke::DrawStroke().
CTypedPtrList<CObList,CStroke*>& strokeList = pDoc->m_strokeList;
POSITION pos = strokeList.GetHeadPosition();
while (pos != NULL)
{
CStroke* pStroke = strokeList.GetNext(pos);
rectStroke = pStroke->GetBoundingRect();//这里得到的应
//该是逻辑坐标是吧。
if (!rectStroke.IntersectRect(&rectStroke, &rectClip))
//3。那这里怎么是屏幕坐标跟逻辑坐标比较
continue;
pStroke->DrawStroke(pDC);
}
}