Share via


GraphicsPathIterator::Rewind, méthode (gdipluspath.h)

La méthode GraphicsPathIterator::Rewind rembobine cet itérateur au début de son chemin d’accès associé.

Syntaxe

void Rewind();

Valeur de retour

None

Notes

La première fois que vous appelez la méthode NextSubpath d’un itérateur, elle obtient la première figure (sous-chemin) du chemin associé de cet itérateur. La deuxième fois, il obtient le deuxième chiffre, et ainsi de suite. Lorsque vous appelez GraphicsPathIterator::Rewind, la séquence redémarre ; autrement dit, après avoir appelé GraphicsPathIterator::Rewind, l’appel suivant à GraphicsPathIterator::NextSubpath obtient la première figure dans le chemin. Les méthodes GraphicsPathIterator::NextMarker et GraphicsPathIterator::NextPathType se comportent de la même façon.

Exemples

L’exemple suivant crée un objet GraphicsPath et ajoute cinq figures au chemin. Le code passe l’adresse de cet objet GraphicsPath à un constructeur GraphicsPathIterator pour créer un itérateur associé au chemin d’accès. Le code appelle la méthode GraphicsPathIterator::NextSubpath de l’itérateur deux fois pour récupérer la deuxième figure dans le chemin. La méthode DrawPath dessine ce chemin en bleu. Ensuite, le code appelle la méthode GraphicsPathIterator::Rewind , puis appelle GraphicsPathIterator::NextSubpath une fois pour obtenir la première figure dans le chemin. La méthode DrawPath dessine cette figure en rouge.


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

Configuration requise

   
Client minimal pris en charge Windows XP, Windows 2000 Professionnel [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête gdipluspath.h (include Gdiplus.h)
Bibliothèque Gdiplus.lib
DLL Gdiplus.dll

Voir aussi

Génération et dessin de tracés

Graphicspath

GraphicsPathIterator

GraphicsPathIterator::NextMarker, méthodes

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath, méthodes

Chemins d’accès