GraphicsPathIterator::Rewind-Methode (gdipluspath.h)

Die GraphicsPathIterator::Rewind-Methode wickelt diesen Iterator an den Anfang des zugeordneten Pfads zurück.

Syntax

void Rewind();

Rückgabewert

Keine

Bemerkungen

Wenn Sie die NextSubpath-Methode eines Iterators zum ersten Mal aufrufen, ruft sie die erste Abbildung (Unterpfad) des zugeordneten Pfads dieses Iterators ab. Beim zweiten Mal wird die zweite Abbildung abgerufen usw. Wenn Sie GraphicsPathIterator::Rewind aufrufen, beginnt die Sequenz von vorn. Das heißt, nachdem Sie GraphicsPathIterator::Rewind aufgerufen haben, ruft der nächste Aufruf von GraphicsPathIterator::NextSubpath die erste Abbildung im Pfad ab. Die Methoden GraphicsPathIterator::NextMarker und GraphicsPathIterator::NextPathType verhalten sich ähnlich.

Beispiele

Im folgenden Beispiel wird ein GraphicsPath-Objekt erstellt und dem Pfad fünf Abbildungen hinzugefügt. Der Code übergibt die Adresse dieses GraphicsPath-Objekts an einen GraphicsPathIterator-Konstruktor , um einen Iterator zu erstellen, der dem Pfad zugeordnet ist. Der Code ruft die GraphicsPathIterator::NextSubpath-Methode des Iterators zweimal auf, um die zweite Abbildung im Pfad abzurufen. Die DrawPath-Methode zeichnet diesen Pfad blau. Als Nächstes ruft der Code die GraphicsPathIterator::Rewind-Methode und anschließend GraphicsPathIterator::NextSubpath einmal auf, um die erste Abbildung im Pfad abzurufen. Die DrawPath-Methode zeichnet diese Abbildung rot.


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

Anforderungen

   
Unterstützte Mindestversion (Client) Windows XP, Windows 2000 Professional [nur Desktop-Apps]
Unterstützte Mindestversion (Server) Windows 2000 Server [nur Desktop-Apps]
Zielplattform Windows
Kopfzeile gdipluspath.h (include Gdiplus.h)
Bibliothek Gdiplus.lib
DLL Gdiplus.dll

Weitere Informationen

Erstellen und Zeichnen von Pfaden

Graphicspath

Graphicspathiterator

GraphicsPathIterator::NextMarker-Methoden

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath-Methoden

Paths