GraphicsPath::GetBounds (Rect*,constMatrix*,constPen*) 方法 (gdipluspath.h)

GraphicsPath::GetBounds方法會取得此路徑的周框。

語法

Status GetBounds(
  [out] Rect         *bounds,
  [in]  const Matrix *matrix,
  [in]  const Pen    *pen
);

參數

[out] bounds

類型: Rect*

接收周框之 Rect 物件的指標。

[in] matrix

類型:const矩陣*

選擇性。 Matrix物件的指標,指定要在計算周框之前套用至此路徑的轉換。 這個路徑不是永久地轉換;該轉換只會用在計算週框期間。 預設值是 NULL

[in] pen

類型:const Pen*

選擇性。 影響周框大小之 Pen 物件的指標。 當路徑是以此參數指定的手寫筆繪製時,以 界限 接收的周框會夠大,以括住這個路徑。 這可確保路徑會由周框括住,即使使用寬畫筆繪製路徑也一樣。 預設值是 NULL

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。

備註

這個方法所傳回的矩形可能大於以指定的畫筆所繪製的方式括住路徑所需的矩形。 矩形的計算方式是允許在尖角的畫筆斜線限制,並允許手寫筆的結束端點。

範例

下列範例會建立具有一條曲線和一個橢圓形的路徑。 此程式碼會使用粗黃色畫筆和細黑色畫筆繪製路徑。 GraphicsPath::GetBounds方法會接收粗黃色畫筆的位址,並計算路徑的周框。 然後程式碼會繪製周框。

VOID GetBoundsExample(HDC hdc)
{
   Graphics graphics(hdc);
   Pen blackPen(Color(255, 0, 0, 0), 1);
   Pen yellowPen(Color(255, 255, 255, 0), 10);
   Pen redPen(Color(255, 255, 0, 0), 1);

   Point pts[] = {Point(120,120), 
                  Point(200,130), 
                  Point(150,200), 
                  Point(130,180)};

   // Create a path that has one curve and one ellipse.
   GraphicsPath path;
   path.AddClosedCurve(pts, 4);
   path.AddEllipse(120, 220, 100, 40);

   // Draw the path with a thick yellow pen and a thin black pen.
   graphics.DrawPath(&yellowPen, &path);
   graphics.DrawPath(&blackPen, &path);
 
   // Get the path's bounding rectangle.
   Rect rect;
   path.GetBounds(&rect, NULL, &yellowPen);
   graphics.DrawRectangle(&redPen, rect);  
}

Color(255, 0, 0, 0)Color(255, 255, 0,  0)

需求

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

另請參閱

使用區域裁剪

建構和繪製路徑

建立路徑漸層

GraphicsPath

矩陣

路徑

Rect