Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


Once a brush has been selected, it would be used on all shapes that are drawn under it,
until you delete or change it. Here is an example:

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

CBrush NewBrush(RGB(255, 2, 5));
CBrush *pBrush;

CPoint Pt[3];

// Top Triangle
Pt[0] = CPoint(125, 10);
Pt[1] = CPoint( 95, 70);
Pt[2] = CPoint(155, 70);

pBrush = pDC->SelectObject(&NewBrush);
pDC->Polygon(Pt, 3);

// Left Triangle
Pt[0] = CPoint( 80, 80);
Pt[1] = CPoint( 20, 110);
Pt[2] = CPoint( 80, 140);

pDC->Polygon(Pt, 3);

// Bottom Triangle
Pt[0] = CPoint( 95, 155);
Pt[1] = CPoint(125, 215);
Pt[2] = CPoint(155, 155);

pDC->Polygon(Pt, 3);

// Right Triangle
Pt[0] = CPoint(170, 80);
Pt[1] = CPoint(170, 140);
Pt[2] = CPoint(230, 110);

pDC->Polygon(Pt, 3);
Free download pdf