GraphicsPathIterator::NextMarker (constGraphicsPath*) 方法 (gdipluspath.h)

GraphicsPathIterator::NextMarker方法會取得這個反覆運算器相關聯路徑的下一個標記分隔區段。

語法

INT NextMarker(
  [out] const GraphicsPath *path
);

參數

[out] path

類型: GraphicsPath*

GraphicsPath物件的指標。 這個方法會設定此 GraphicsPath 物件的資料點,以符合所擷取區段的資料點。

傳回值

類型: INT

這個方法會傳回所擷取區段中的資料點數目。 如果沒有其他標記分隔區段可供擷取,這個方法會傳回 0。

備註

路徑具有定義其線條和曲線的資料點陣列。 您可以呼叫路徑的 SetMarker 方法,將陣列中的特定點指定為標記。 這些標記點會將路徑分割成區段。

第一次呼叫反覆運算器的 GraphicsPathIterator::NextMarker 方法時,它會取得該反覆運算器相關聯路徑的第一個標記分隔區段。 第二次,它會取得第二個區段,依此類錯。 每次呼叫 GraphicsPathIterator::NextSubpath時,都會傳回所擷取區段中的資料點數目。 當沒有剩餘的區段時,它會傳回 0。

範例

下列範例會建立 GraphicsPath 物件,並將五個圖形新增至路徑。 對 SetMarker 方法的呼叫會將兩個標記放在路徑中。 第一個標記位於圖形的結尾,而第二個標記位於圖形中間。 程式碼會將 GraphicsPath 物件的位址傳遞至 GraphicsPathIterator 建構函式,以建立與路徑相關聯的反覆運算器。 然後,程式碼會呼叫反覆運算器的 GraphicsPathIterator::NextMarker 方法兩次,以取得路徑的第二個標記分隔區段。 最後,程式碼會繪製路徑的擷取區段。


VOID NextMarkerExample(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a graphics path with five figures (subpaths).
   GraphicsPath path;

   path.AddRectangle(Rect(20, 20, 60, 30));
   path.SetMarker();                          // first marker

   path.AddLine(100, 20, 160, 50);
   path.AddArc(180, 20, 60, 30, 0.0f, 180.0f);

   path.AddRectangle(Rect(260, 20, 60, 30));

   path.AddLine(340, 20, 400, 50);
   path.SetMarker();                          // second marker
   path.AddArc(340, 20, 60, 30, 0.0f, 180.0f);
   path.CloseFigure();
  
   path.AddRectangle(Rect(420, 20, 60, 30));
 
   // Create an iterator, and associate it with the path.
   GraphicsPathIterator iterator(&path);

   // Get the second marker-delimited section by calling NextMarker twice.
   GraphicsPath section;
   INT count;
   count = iterator.NextMarker(&section);
   count = iterator.NextMarker(&section);

   // The variable "count" now holds the number of 
   // data points in the second marker-delimited section.

   // Draw the retrieved section.
   Pen bluePen(Color(255, 0, 0, 255));
   graphics.DrawPath(&bluePen, &section);
}

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdipluspath.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

建構和繪製路徑

GetPathData

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::NextSubpath 方法

NextMarker

路徑