Region::GetBounds(Rect*,constGraphics*) メソッド (gdiplusheaders.h)

Region::GetBounds メソッドは、この領域を囲む四角形を取得します。

構文

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

パラメーター

rect

外側の四角形を受け取る Rect オブジェクトへのポインター。

g

この領域と四角形のデバイス座標を計算するために必要なワールド変換とページ変換を含む Graphics オブジェクトへのポインター。

戻り値

種類: 状態

メソッドが成功した場合は、 Status 列挙の要素である Ok を返します。

メソッドが失敗した場合は、 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);
}

必要条件

   
Header gdiplusheaders.h

関連項目

リージョン

Graphicspath

Rect

状態