Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


To draw an arc, you can use the CDC::Arc() method whose syntax is:

BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);

Besides the left (x1, y1) and the right (x2, y2) borders of the rectangle in which the arc
would fit, an arc must specify where it starts and where it ends. These additional points
are set as the (x3, y3) and (x4, y4) points of the figure. Based on this, the above arc can
be illustrated as follows:

Here is an example:

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

An arc can also be drawn using the location and size of the rectangle it would fit in. Such
a rectangle can be passed to the Arc() method as a RECT or a CRect object. In this case,
you must define the beginning and end of the arc as two POINT or CPoint values. The
syntax used is:

BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd);

Here is an example that produces the same result as above:
Free download pdf