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

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

語法

Status GetBounds(
  Rect           *rect,
  const Graphics *g
);

參數

rect

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

g

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

傳回值

類型: 狀態

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

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

備註

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

範例

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

VOID Example_GetBoundsRect(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));
    Rect 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);
}

需求

   
標頭 gdiplusheaders.h

另請參閱

區域

GraphicsPath

Rect

狀態