Region::Union (constRect&) 方法 (gdiplusheaders.h)

Region::Union 方法會將這個區域更新為 (交集和非相互關聯) 本身的所有部分,以及指定矩形內部的所有部分。

語法

Status Union(
  const Rect & rect
);

參數

rect

用來更新此區域的矩形參考。

傳回值

類型: 狀態

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

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

備註

範例

下列範例會從路徑建立區域,然後使用矩形來更新區域。 更新的區域是路徑區域和矩形的聯集。

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

   Rect rect(65, 15, 70, 45);
   GraphicsPath path;
   SolidBrush solidBrush(Color(255, 255, 0, 0));

   path.AddClosedCurve(points, 6);

   // Create a region from a path.
   Region pathRegion(&path);

   // Form the union of the region and a rectangle.
   pathRegion.Union(rect);

   graphics.FillRegion(&solidBrush, &pathRegion);
}

規格需求

需求
標頭 gdiplusheaders.h

另請參閱

區域

Rect

狀態