Region::GetBounds (RectF*,constGraphics*) 方法 (gdiplusheaders.h)

Region::GetBounds 方法會取得將這個區域括住的矩形。

語法

Status GetBounds(
  [out] RectF          *rect,
  [in]  const Graphics *g
);

參數

[out] rect

類型: RectF*

接收封閉矩形之 RectF 物件的指標。

[in] g

類型: const 圖形*

Graphics 物件的指標,其中包含計算此區域和矩形之裝置座標所需的世界和頁面轉換。

傳回值

類型: 狀態

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

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

備註

圖形物件的目前世界和頁面轉換可用來計算在顯示裝置上繪製的區域和矩形。 Region::GetBounds 所傳回的矩形不一定是最小的可能矩形。

範例

下列範例會從路徑建立區域、取得區域的封入矩形,然後顯示兩者。

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

   Point points[] = {
      Point(110, 20),
      Point(120, 30),
      Point(100, 60),
      Point(120, 70),
      Point(150, 60),
      Point(140, 10)};

   GraphicsPath path;
    SolidBrush solidBrush(Color(255, 255, 0, 0));
    Pen pen(Color(255, 0, 0, 0));
    RectF rect;

   path.AddClosedCurve(points, 6);

    // Create a region from a path.
    Region pathRegion(&path);
    
    // Get the region's enclosing rectangle.
    pathRegion.GetBounds(&rect, &graphics);

    // Show the region and the enclosing rectangle.
    graphics.FillRegion(&solidBrush, &pathRegion);
    graphics.DrawRectangle(&pen, rect);
}

規格需求

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

另請參閱

GraphicsPath

區域