GraphicsPathIterator::Rewind method (gdipluspath.h)

The GraphicsPathIterator::Rewind method rewinds this iterator to the beginning of its associated path.

Syntax

void Rewind();

Return value

None

Remarks

The first time you call the NextSubpath method of an iterator, it gets the first figure (subpath) of that iterator's associated path. The second time, it gets the second figure, and so on. When you call GraphicsPathIterator::Rewind, the sequence starts over; that is, after you call GraphicsPathIterator::Rewind, the next call to GraphicsPathIterator::NextSubpath gets the first figure in the path. The GraphicsPathIterator::NextMarker and GraphicsPathIterator::NextPathType methods behave similarly.

Examples

The following example creates a GraphicsPath object and adds five figures to the path. The code passes the address of that GraphicsPath object to a GraphicsPathIterator constructor to create an iterator that is associated with the path. The code calls the iterator's GraphicsPathIterator::NextSubpath method twice to retrieve the second figure in the path. The DrawPath method draws that path in blue. Next, the code calls the GraphicsPathIterator::Rewind method and then calls GraphicsPathIterator::NextSubpath once to obtain the first figure in the path. The DrawPath method draws that figure in red.


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);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Constructing and Drawing Paths

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::NextMarker Methods

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath Methods

Paths