Share via


Graphics::IntersectClip (constRectF&) 方法 (gdiplusgraphics.h)

Graphics::IntersectClip 方法會將這個 Graphics 物件的裁剪區域更新為與這個 Graphics 物件目前裁剪區域交集的指定矩形部分。

語法

Status IntersectClip(
  const RectF & rect
);

參數

rect

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

傳回值

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

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

備註

範例

下列範例會設定裁剪區域,並更新裁剪區域。 然後繪製矩形來示範有效的裁剪區域。

VOID Example_IntersectClip2(HDC hdc)
{
   Graphics graphics(hdc);

   // Set the clipping region.
   RectF clipRect(0.5f, 0.5f, 200.5f, 200.5f);
   graphics.SetClip(clipRect);

   // Update the clipping region to the portion of the rectangle that
   // intersects with the current clipping region.
   RectF intersectRect(100.5f, 100.5f, 200.5f, 200.5f);
   graphics.IntersectClip(intersectRect);

   // Fill a rectangle to demonstrate the effective clipping region.
   graphics.FillRectangle(&SolidBrush(Color(255, 0, 0, 255)), 0, 0, 500, 500);

   // Reset the clipping region to infinite.
   graphics.ResetClip();

   // Draw clipRect and intersectRect.
   graphics.DrawRectangle(&Pen(Color(255, 0, 0, 0)), clipRect);
   graphics.DrawRectangle(&Pen(Color(255, 255, 0, 0)), intersectRect);
}

規格需求

需求
標頭 gdiplusgraphics.h

另請參閱

裁剪

使用區域裁剪

GetClipBounds 方法

圖形

Graphics::GetClip

RectF

SetClip 方法

狀態