Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 9 Strings Visual C++ and MFC Fundamentals


8.1.2 Changing the Coordinate System......................................................


As seen above, the default coordinate system has its origin set on the top-left section of
the screen. The horizontal axis moves positively from the origin to the right direction.
The vertical axis moves from the origin to the bottom direction. To illustrate this, we will
draw a circle with a radius whose center is at the origin (0, 0) with a radius of 50 units.
We will also draw a line from the origin (0, 0) to (100, 100):

void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

// A circle whose center is at the origin (0, 0)
pDC->Ellipse(-50, -50, 50, 50);

// A line that starts at (0, 0) and ends at (100, 100)
pDC->MoveTo(0, 0);
pDC->LineTo(100, 100);
}
Free download pdf