void CMy010_SDIView::OnDraw(CDC* pDC) { CMy010_SDIDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here // Get the number of lines in the document int liCount = pDoc->GetLineCount(); // Are there any lines in the document? if (liCount) { int liPos; CLine *lptLine; // Loop through the lines in the document for (liPos = 0; liPos < liCount; liPos++) { // Get the from and to point for each line lptLine = pDoc->GetLine(liPos); // Draw the line lptLine->Draw(pDC); } } }
void CMy010_SDIView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default // Check to see if the left mouse button is down if ((nFlags & MK_LBUTTON) == MK_LBUTTON) { // Have we captured the mouse? if (GetCapture() == this) { // Get the Device Context CClientDC dc(this); // Add the line to the document CLine *pLine = GetDocument()->AddLine(m_ptPrevPos, point); // Draw the current stretch of line pLine->Draw(&dc); // Save the current point as the previous point m_ptPrevPos = point; } } CView::OnMouseMove(nFlags, point); }