Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 7: GDI Accessories and Tools Visual C++ and MFC Fundamentals


While the Polyline() method starts the first line at lpPoints[0], the PolylineTo() member
function does not control the beginning of the first line. Like the LineTo() method, it
simply starts drawing, which would mean it starts at the origin (0, 0). For this reason, if
you want to control the starting point of the PolylineTo() drawing, you can use the
MoveTo() method:

void CExoView::OnDraw(CDC* pDC)
{
CPoint Pt[7];

Pt[0] = CPoint(20, 50);
Pt[1] = CPoint(180, 50);
Pt[2] = CPoint(180, 20);
Pt[3] = CPoint(230, 70);
Pt[4] = CPoint(180, 120);
Pt[5] = CPoint(180, 90);
Pt[6] = CPoint(20, 90);

pDC->MoveTo(20, 30);
pDC->PolylineTo(Pt, 7);
pDC->LineTo(20, 110);
}
Free download pdf