Share via


GraphicsPathIterator::NextSubpath(INT*,INT*,BOOL*) , méthode (gdipluspath.h)

La méthode GraphicsPathIterator::NextSubpath obtient l’index de début et l’index de fin du sous-chemin suivant (figure) dans le chemin associé de cet itérateur.

Syntaxe

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

Paramètres

startIndex

Pointeur vers un INT qui reçoit l’index de départ.

endIndex

Pointeur vers un INT qui reçoit l’index de fin.

isClosed

Pointeur vers un BOOL qui reçoit une valeur qui indique si la figure obtenue est fermée. Si la figure est fermée, la valeur reçue est TRUE ; sinon, la valeur reçue est FALSE.

Valeur retournée

Cette méthode retourne le nombre de points de données dans la figure suivante. S’il n’y a plus de figures dans le chemin d’accès, cette méthode retourne 0.

Notes

La première fois que vous appelez la méthode GraphicsPathIterator::NextSubpath d’un itérateur, il obtient les index de la première figure (sous-chemin) du chemin associé de cet itérateur. La deuxième fois, il obtient les index du deuxième chiffre, et ainsi de suite. Chaque fois que vous appelez GraphicsPathIterator::NextSubpath, il retourne le nombre de points de données dans la figure dont les index ont été récupérés. Lorsqu’il n’y a pas de chiffres restants, il retourne 0.

Exemples

L’exemple suivant crée un objet GraphicsPath et ajoute cinq figures au chemin d’accès. 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 trois fois pour obtenir l’index de début et l’index de fin de la troisième figure du chemin d’accès. Ensuite, le code appelle la méthode GraphicsPathIterator::CopyData de l’itérateur pour récupérer les points de données de la troisième figure.

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

Configuration requise

   
En-tête gdipluspath.h

Voir aussi

Génération et dessin de tracés

GraphicsPath::GetPathData

Graphicspath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::GetSubpathCount

GraphicsPathIterator::NextMarker, méthodes

NextSubpath

Chemins d’accès