想画一个复杂多边形,并填充,这种多边形是由直线,圆弧或者椭圆组合而成的,因此不能单独使用api的polygon来完成,现在的语言环境只能使用API来写,不需要使用GDI+,现在我的代码有如下问题,多边形的直线段组成的区域绘制不出来,而由椭圆或者圆弧组成的区域却能绘制出来,麻烦哪位解决一下,稍分少,可以再加!
m_lOldBrush = W32API.SelectObject(m_lhDC, m_lBrush);
m_lOldPen = W32API.SelectObject(m_lhDC, m_lPen); IGeometryCollection pGeoCol = this.m_pPolygon as IGeometryCollection;
object objMissing = Type.Missing;
for (int i = 0; i < pGeoCol.GeometryCount; i++)
{
W32API.BeginPath(m_lhDC);
IRing pRing = pGeoCol.get_Geometry(i) as IRing;
ISegmentCollection pSegmentCollection = pRing as ISegmentCollection;
for (int j = 0; j < pSegmentCollection.SegmentCount; j++)
{
ISegment pSegment = pSegmentCollection.get_Segment(j);
if (pSegment is ILine)
{
......
W32API.Polyline(m_lhDC, ref ptArray[0], 2);
}
else if(pSegment is ICircularArc)
{
ICircularArc pCircularArc = pSegment as ICircularArc;
if (pCircularArc.IsLine==false)
{
................
if (pCircularArc.IsCounterClockwise == false)
{
W32API.Arc(m_lhDC, leftTopPt.x, leftTopPt.y, rightBottomPt.x, rightBottomPt.y, toPt.x, toPt.y, fromPt.x, fromPt.y);
}
else
{
W32API.Arc(m_lhDC, leftTopPt.x, leftTopPt.y, rightBottomPt.x, rightBottomPt.y, fromPt.x, fromPt.y, toPt.x, toPt.y);
}
}
} }
W32API.CloseFigure(m_lhDC);
W32API.EndPath(m_lhDC);
int hRgn = W32API.PathToRegion(m_lhDC);
W32API.FillRgn(m_lhDC, hRgn, m_lBrush);
W32API.DeleteObject(hRgn);
}
m_lBrush = W32API.SelectObject(m_lhDC, m_lOldBrush);
m_lPen = W32API.SelectObject(m_lhDC, m_lOldPen);
代码中的"-----------",为了代码简洁,省略了一部分代码,麻烦高手看一下.
m_lOldBrush = W32API.SelectObject(m_lhDC, m_lBrush);
m_lOldPen = W32API.SelectObject(m_lhDC, m_lPen); IGeometryCollection pGeoCol = this.m_pPolygon as IGeometryCollection;
object objMissing = Type.Missing;
for (int i = 0; i < pGeoCol.GeometryCount; i++)
{
W32API.BeginPath(m_lhDC);
IRing pRing = pGeoCol.get_Geometry(i) as IRing;
ISegmentCollection pSegmentCollection = pRing as ISegmentCollection;
for (int j = 0; j < pSegmentCollection.SegmentCount; j++)
{
ISegment pSegment = pSegmentCollection.get_Segment(j);
if (pSegment is ILine)
{
......
W32API.Polyline(m_lhDC, ref ptArray[0], 2);
}
else if(pSegment is ICircularArc)
{
ICircularArc pCircularArc = pSegment as ICircularArc;
if (pCircularArc.IsLine==false)
{
................
if (pCircularArc.IsCounterClockwise == false)
{
W32API.Arc(m_lhDC, leftTopPt.x, leftTopPt.y, rightBottomPt.x, rightBottomPt.y, toPt.x, toPt.y, fromPt.x, fromPt.y);
}
else
{
W32API.Arc(m_lhDC, leftTopPt.x, leftTopPt.y, rightBottomPt.x, rightBottomPt.y, fromPt.x, fromPt.y, toPt.x, toPt.y);
}
}
} }
W32API.CloseFigure(m_lhDC);
W32API.EndPath(m_lhDC);
int hRgn = W32API.PathToRegion(m_lhDC);
W32API.FillRgn(m_lhDC, hRgn, m_lBrush);
W32API.DeleteObject(hRgn);
}
m_lBrush = W32API.SelectObject(m_lhDC, m_lOldBrush);
m_lPen = W32API.SelectObject(m_lhDC, m_lOldPen);
代码中的"-----------",为了代码简洁,省略了一部分代码,麻烦高手看一下.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货