GraphicsPathIterator::NextSubpath (INT*,INT*,BOOL*) 方法 (gdipluspath.h)

GraphicsPathIterator::NextSubpath 方法获取此迭代器关联路径中) (下一个子路径的起始索引和结束索引。

语法

INT NextSubpath(
  INT  *startIndex,
  INT  *endIndex,
  BOOL *isClosed
);

parameters

startIndex

指向接收起始索引的 INT 的指针。

endIndex

指向接收结束索引的 INT 的指针。

isClosed

指向 BOOL 的指针,该 BOOL 接收一个值,该值指示获取的数字是否关闭。 如果数字关闭,则收到的值为 TRUE;否则,收到的值为 FALSE

返回值

此方法返回下一图中的数据点数。 如果路径中没有更多数字,则此方法返回 0。

注解

首次调用迭代 器的 GraphicsPathIterator::NextSubpath 方法时,它会获取该迭代器关联路径) 第一个图形 (子路径的索引。 第二次,它获取第二个数字的索引,依此进行。 每次调用 GraphicsPathIterator::NextSubpath 时,它都会返回检索其索引的图中的数据点数。 如果没有剩余数字,则返回 0。

示例

以下示例创建 一个 GraphicsPath 对象,并将五个图形添加到路径。 代码将该 GraphicsPath 对象的地址传递给 GraphicsPathIterator 构造函数,以创建与路径关联的迭代器。 代码调用迭代器的 GraphicsPathIterator::NextSubpath 方法三次,以获取路径第三个图形的起始索引和结束索引。 然后,代码调用迭代器的 GraphicsPathIterator::CopyData 方法来检索第三个图形的数据点。

VOID NextSubpathExample2(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a graphics path with five figures (subpaths).
   GraphicsPath path;

   path.AddRectangle(Rect(20, 20, 60, 30));   // Subpath count is 1.

   path.AddLine(100, 20, 160, 50);            // Subpath count is 2.
   path.AddArc(180, 20, 60, 30, 0.0f, 180.0f);

   path.AddRectangle(Rect(260, 20, 60, 30));  // Subpath count is 3.

   path.AddLine(340, 20, 400, 50);            // Subpath count is 4.
   path.AddArc(340, 20, 60, 30, 0.0f, 180.0f);
   path.CloseFigure();
  
   path.AddRectangle(Rect(420, 20, 60, 30));  // Subpath count is 5.

   // Create an iterator, and associate it with the path.
   GraphicsPathIterator iterator(&path);

   // Call NextSubpath three times to get the starting and ending
   // indices for the third figure.
   INT start;
   INT end;
   BOOL isClosed;
   INT count;
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);

   // Get the third figure's data points.
   PointF* points = new PointF[count];
   BYTE* types = new BYTE[count];
   iterator.CopyData(points, types, start, end);

   // Draw the third figure's data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < count; ++j)
      graphics.FillEllipse(
         &brush,
         points[j].X - 3.0f,
         points[j].Y - 3.0f,
         6.0f,
         6.0f);

   delete points;
   delete types;
}

要求

   
标头 gdipluspath.h

另请参阅

构造并绘制轨迹

GraphicsPath::GetPathData

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::GetSubpathCount

GraphicsPathIterator::NextMarker 方法

NextSubpath

路径