RectF::Union メソッド (gdiplustypes.h)

RectF::Union メソッドは、2 つの四角形の和集合を決定し、その結果を RectF オブジェクトに格納します。

構文

BOOL Union(
  [out] RectF &       c,
  [in]  const RectF & a,
  [in]  const RectF & b
);

パラメーター

[out] c

型: RectF&

2 つの四角形の和集合を受け取る RectF オブジェクトへの参照。

[in] a

型: const RectF&

共用体を形成するために使用される 2 つの四角形の 1 つを参照します。

[in] b

型: const RectF&

共用体を形成するために使用される 2 つの四角形の 1 つを参照します。

戻り値

種類: BOOL

2 つの四角形の和集合が空でない場合、このメソッドは TRUE を返します。それ以外の場合は、 FALSE を返します。

注釈

GDI+ では、2 つの四角形の和集合は、2 つの四角形を囲む最小の四角形です。 四角形の幅または高さが 0 以下の場合、四角形は空として定義されます。

次の例では、3 つの四角形を作成します。 コードは、最初の 2 つの四角形の和集合を形成し、結果を 3 番目の四角形に格納します。 このコードでは、共用体が空でないかどうかを判断し、存在する場合は共用体を描画します。

VOID Example_UnionABC(HDC hdc)
{
   Graphics graphics(hdc);
   Pen* pGreenPen;

   // Create three RectF objects.
   RectF rectA(50, 50, 200, 100);
   RectF rectB(70, 20, 100, 200);
   RectF rectC;

   // Determine the union of rectA and rectB, and store the result in rectC.
   if(rectC.Union(rectC, rectA, rectB))
   {
      // rectC is not empty.
      // Draw the union with a thick green pen.
      pGreenPen = new Pen(Color(255, 0, 255, 0), 7);
      graphics.DrawRectangle(pGreenPen, rectC);
      delete pGreenPen;
   }
   // Draw rectA and rectB with a thin black pen.
   Pen blackPen(Color(255, 0, 0, 0), 1);
   graphics.DrawRectangle(&blackPen, rectA);
   graphics.DrawRectangle(&blackPen, rectB);}

要件

要件
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdiplustypes.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

こちらもご覧ください

Intersect メソッド

ペン、直線、および四角形

Rect

RectF

ペンを使用した直線と四角形の描画