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

Region::Intersect 方法會將這個區域更新為與指定矩形內部交集的本身部分。

語法

Status Intersect(
  const Rect & rect
);

參數

rect

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

傳回值

類型: 狀態

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

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

備註

範例

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

VOID Example_IntersectRect(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);   
    
   // Update the region to the portion that intersects with the rectangle.
   pathRegion.Intersect(rect);

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

規格需求

   
標頭 gdiplusheaders.h

另請參閱

區域

Rect

狀態