Partager via


RectF.Intersect(const RectF&) method

Applies to: desktop apps only

The RectF::Intersect method replaces this rectangle with the intersection of itself and another rectangle.

Syntax

BOOL Intersect(
  [in]  const RectF& rect
);

Parameters

  • rect [in]
    Type: const RectF&

    Reference to a rectangle that will be intersected with this rectangle.

Return value

Type:

Type: BOOL

If the intersection of the two rectangles is not empty, this method returns TRUE; otherwise, it returns FALSE.

Examples

The following example creates three RectF objects, draws the first two rectangles, and then draws the third rectangle that indicates the intersection of the first two rectangles.

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

   // Create two RectF objects.
   RectF rect1(50, 50, 200, 100);
   RectF rect2(70, 20, 100, 200);

   // Draw rect1 and rect2 with a thin black pen.
   Pen blackPen(Color(255, 0, 0, 0), 1);
   graphics.DrawRectangle(&blackPen, rect1);
   graphics.DrawRectangle(&blackPen, rect2);

   // Form the intersection of rect1 and rect2, and store
   // the result in rect1.
   rect1.Intersect(rect2);

   // Draw the new rect1 with a thick green pen.
   Pen greenPen(Color(255, 0, 255, 0), 7);
   graphics.DrawRectangle(&greenPen, rect1);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplustypes.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

RectF

Intersect Methods

Rect

Using a Pen to Draw Lines and Rectangles

Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012