void CSketcherView::OnDraw(CDC* pDC) { CSketcherDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(!pDoc) return; POSITION aPos = pDoc->GetListHeadPosition(); CElement* pElement = 0; // Store for an element pointer while(aPos) // Loop while aPos is not null { pElement = pDoc->GetNext(aPos); // Get the current element pointer // If the element is visible... if(pDC->RectVisible(pElement->GetBoundRect())) pElement->Draw(pDC, m_pSelected);// ...draw it } }