class CRegionView : public CView
{
..
// Attributes
public:
CRegionDoc* GetDocument();
CRgn m_rgnStar;
..
};
CRegionView::CRegionView()
{
..
m_rgnStar.CreatePolygonRgn(points, 11, WINDING);
}
..
void CRegionView::OnDraw(CDC* pDC)
{
CRgn rgn;
..
rgn.CreateRectRgn(0, 0, 0, 0);
..
rgn.CopyRgn(&m_rgnStar);
rgn.OffsetRgn(x, y);
..
pDC->FillRgn(&rgn, &brush);
pDC->FrameRgn(&rgn, &brush, 1, 1);
..
}
void CRegionTextView::OnDraw(CDC* pDC)
{
CRgn rgn1, rgn2;
..
CFont *pOldFont = pDC->SelectObject(&font);
..
pDC->BeginPath();
pDC->TextOut(x, y, str);
pDC->EndPath();
pDC->SelectObject(pOldFont);
rgn1.CreateFromPath(pDC);
rgn1.GetRgnBox(&rcText);
rgn2.CreateRectRgnIndirect(&rcText);
rgn1.CombineRgn(&rgn2, &rgn1, RGN_DIFF);
pDC->SelectClipRgn(&rgn1);
..
pDC->StretchBlt(rcText.left, rcText.top, rcText.Width(), rcText.Height(),
&MemDC, 0, 0, 400, 200, SRCCOPY);
MemDC.SelectObject(pOldBitmap);
}