GraphicsPathIterator::Rewind 方法 (gdipluspath.h)

GraphicsPathIterator::Rewind 方法将此迭代器倒回其关联路径的开头。

语法

void Rewind();

返回值

备注

首次调用迭代器的 NextSubpath 方法时,它将获取该迭代器关联路径) (子路径的第一个图。 第二次,它获取第二个数字,依此。 调用 GraphicsPathIterator::Rewind 时,序列将重新开始;也就是说,调用 GraphicsPathIterator::Rewind 后,对 GraphicsPathIterator::NextSubpath 的下一次调用将获取路径中的第一个图。 GraphicsPathIterator::NextMarkerGraphicsPathIterator::NextPathType 方法的行为类似。

示例

以下示例创建 一个 GraphicsPath 对象,并将五个图形添加到路径。 代码将该 GraphicsPath 对象的地址传递给 GraphicsPathIterator 构造函数,以创建与路径关联的迭代器。 代码调用迭代器的 GraphicsPathIterator::NextSubpath 方法两次,以检索路径中的第二个图。 DrawPath 方法以蓝色绘制该路径。 接下来,代码调用 GraphicsPathIterator::Rewind 方法,然后调用 GraphicsPathIterator::NextSubpath 一次以获取路径中的第一个图。 DrawPath 方法以红色绘制该图。


VOID RewindExample(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);

   // Get the second subpath by calling NextSubpath twice.
   GraphicsPath subpath;
   BOOL isClosed;
   INT count;
   count = iterator.NextSubpath(&subpath, &isClosed);
   count = iterator.NextSubpath(&subpath, &isClosed);

   // Draw the second figure in blue.
   Pen bluePen(Color(255, 0, 0, 255));
   graphics.DrawPath(&bluePen, &subpath);

   // Rewind the iterator, and get the first figure in the path.
   iterator.Rewind();
   count = iterator.NextSubpath(&subpath, &isClosed);

   // Draw the first figure in red.
   Pen redPen(Color(255, 255, 0, 0));
   graphics.DrawPath(&redPen, &subpath);
}

要求

   
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdipluspath.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

构造并绘制轨迹

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::NextMarker 方法

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath 方法

路径