Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


void CExoView::OnDraw(CDC* pDC)
{
CRect Recto(20, 20, 226, 144);
CPoint Pt1(202, 115);
CPoint Pt2(105, 32);
pDC->Arc(Recto, Pt1, Pt2);
}

Besides the Arc() method, the CDC class provides the ArcTo() member function used to
draw an arc. It also comes in two syntaxes as follows:

BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd);

This method uses the same arguments as Arc(). The difference is that while Arc() starts
drawing at (x3, y3), ArcTo() does not inherently control the drawing starting point. It
refers to the current point, exactly like the LineTo() (and the PolylineTo()) method.
Therefore, if you want to specify where the drawing should start, can call
CDC::MoveTo() before ArcTo(). Here is an example:

void CExoView::OnDraw(CDC* pDC)
{
CRect Recto(20, 20, 226, 144);
CPoint Pt1(202, 115);
CPoint Pt2(105, 32);

pDC->MoveTo(207, 155);
pDC->ArcTo(Recto, Pt1, Pt2);
}

6.3.12..The Arc's Direction.............................................................................


Here is and arc we drew earlier with a call to Arc():

void CExoView::OnDraw(CDC* pDC)
{
pDC->Arc(20, 20, 226, 144, 202, 115, 105, 32);
Free download pdf