GDI转换到GDI+之后的困惑?
需求:在OnPaint中绘制一个多边形,先绘制多边形的边框和背景色,然后再绘制多边形的填充色,在GDI中没有任何问题。可是在我将代码修改为GDI+的方式后居然发现边框或背景色会覆盖填充色,真是百思不得其解,盼望高人指点迷津啊!
下面是修改为GDI+之后的部分代码:
if (!IsContourClosed() || IsTransparent())
{
graphics.DrawLines(&pen, lpUnRotPts, m_nRotNumPts);
}
else
{
SolidBrush* pSolidBrush = NULL;
HatchBrush* pHatchBrush = NULL;
if (dwHatchStyle != 99)
{
#if _WIN32_WCE
pSolidBrush = new SolidBrush(crNewBkgnd);
#else
pHatchBrush = new HatchBrush((HatchStyle)dwHatchStyle, crNewFrgnd, crNewBkgnd);
#endif
}
else
{
pSolidBrush = new SolidBrush(crNewBkgnd);
}
if (pSolidBrush)
{
//graphics.FillPolygon(pSolidBrush, lpUnRotPts, m_nRotNumPts);//此处填充背景
delete pSolidBrush;
}
else
{
graphics.FillPolygon(pHatchBrush, lpUnRotPts, m_nRotNumPts);
delete pHatchBrush;
}
graphics.DrawPolygon(&pen, lpUnRotPts, m_nRotNumPts);//此处绘制边框
}
delete lpUnRotPts;
DrawFill(pDC,2);//此处绘制填充色
//为什么此处的填充色会被边框或背景覆盖???