GraphicsPathIterator::NextSubpath (constGraphicsPath*,BOOL*) 方法 (gdipluspath.h)

GraphicsPathIterator::NextSubpath 方法會從這個反覆運算器的相關聯路徑取得下一個圖 (子路徑) 。

語法

INT NextSubpath(
  [out] const GraphicsPath *path,
  [out] BOOL               *isClosed
);

參數

[out] path

類型: GraphicsPath*

GraphicsPath 物件的指標。 這個方法會設定此 GraphicsPath 對象的數據點,以符合所擷取之圖形的數據點。

[out] isClosed

類型: BOOL*

BOOL 的指標,接收值,指出擷取的圖形是否已關閉。 如果圖表已關閉,則收到的值為 TRUE;否則,收到的值為 FALSE

傳回值

類型: INT

這個方法會傳回所擷取之圖中的數據點數目。 如果沒有其他要擷取的數字,這個方法會傳回 0。

備註

第一次呼叫反覆運算器的 GraphicsPathIterator::NextSubpath 方法時,它會取得該反覆運算器相關聯路徑的第一個圖 (子路徑) 。 第二次,它會取得第二個圖形,依此類計算。 每次呼叫 GraphicsPathIterator::NextSubpath 時,都會傳回所擷取之圖形中的數據點數目。 當沒有剩餘的圖表時,它會傳回 0。

範例

下列範例會建立 GraphicsPath 物件,並將五個圖表新增 (也稱為子路徑) 路徑。 程序代碼會將 GraphicsPath 物件的地址傳遞至 GraphicsPathIterator 建構函式,以建立與路徑相關聯的反覆運算器。 程序代碼會呼叫反覆運算器的 GraphicsPathIterator::NextSubpath 方法兩次,以從路徑擷取第二個圖形 (子路徑) 。 然後程式代碼會呼叫 Graphics 物件的 DrawPath 方法,以繪製該個別的子路徑。


VOID NextSubpathExample(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);

   // The variable "count" now holds the number of 
   // data points in the second subpath.

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

規格需求

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

另請參閱

建構和繪製路徑

GetPathData

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::GetSubpathCount

GraphicsPathIterator::NextMarker 方法

NextSubpath

路徑