Visual C++ and MFC Fundamentals Chapter 9: Strings
pDC->SelectObject(pnOld);
pDC->SelectObject(brOld);
}
To control your own unit system, the orientation of the axes or how the application
converts the units used on your application, use either the MM_ISOTROPIC or the
MM_ANISOTROPIC mapping modes. The first thing you should do is to call the
CDC::SetMapMode() member function and specify one of these two constants (either
MM_ISOTROPIC or MM_ANISOTROPIC). Here is an example:
void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));
CBrush BrushAqua(RGB(0, 255, 255));
CBrush *brOld;
CPen *pnOld;
pnOld = pDC->SelectObject(&PenRed);
brOld = pDC->SelectObject(&BrushAqua);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetViewportOrg(220, 150);
// Draw a square with a red border and an aqua background
pDC->Rectangle(-100, -100, 100, 100);
CPen BluePen(PS_SOLID, 1, RGB(0, 0, 255));
pnOld = pDC->SelectObject(&BluePen);
// Diagonal line at 45 degrees starting at the origin (0, 0)
pDC->MoveTo(0, 0);
pDC->LineTo(120, 120);
pDC->SelectObject(pnOld);
pDC->SelectObject(brOld);
}