Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 8 GDI Orientation and Transformations Visual C++ and MFC Fundamentals


8.1 The Default Coordinate System.................................................................


8.1.1 Introduction...........................................................................................


When drawing on Microsoft Windows, the coordinates of the drawing area are located on
the upper-left corner of the screen. Everything positioned on the screen takes its reference
on that point, as we have seen in Lesson 6. That point can be illustrated in a Cartesian
coordinate system as (0,0) where the horizontal axis moves from (0,0) to the right and the
vertical axis moves from (0,0) down:

This starting origin is only the default coordinate system of the operating system.
Therefore, if you draw a shape with the following call, Ellipse(-100, -100, 100, 100), you
would get a circle whose center is positioned on the top-left corner of the screen. In this
case, only the lower-right 3/4 of the circle would be seen:

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

CPen PenBlue;

// Blue solid pen width = 1
PenBlue.CreatePen(PS_SOLID, 1, RGB(0, 12, 255));

CPen *pOld = pDC->SelectObject(&PenBlue);
pDC->Ellipse(-100, -100, 100, 100);
pDC->SelectObject(pOld);
}
Free download pdf