Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 9 Strings Visual C++ and MFC Fundamentals


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);
pDC->SetWindowExt(640, 640);
pDC->SetViewportExt(480, -480);

// 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);
}
Free download pdf