Visual C++ and MFC Fundamentals Chapter 8 GDI Orientation and Transformations
pDC->SelectObject(pBrush);
}
If you want to use a different brush, you should create a new one. Here is an example:
void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush BrushGreen(RGB(0, 125, 5));
CBrush BrushRed(RGB(255, 2, 5));
CBrush BrushYellow(RGB(250, 255, 5));
CBrush BrushBlue(RGB(0, 2, 255));
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(&BrushGreen);
pDC->Polygon(Pt, 3);
// Left Triangle
Pt[0] = CPoint( 80, 80);
Pt[1] = CPoint( 20, 110);
Pt[2] = CPoint( 80, 140);
pBrush = pDC->SelectObject(&BrushRed);
pDC->Polygon(Pt, 3);