Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Rect.Contains(Rect&) method

Applies to: desktop apps only

The Rect::Contains method determines whether another rectangle is inside this rectangle.

Syntax

BOOL Contains(
  [in]  Rect& rect
);

Parameters

rect [in]

Type: Rect&

Reference to a rectangle to test against this rectangle.

Return value

Type:

Type: BOOL

If the rectangle is inside this rectangle, this method returns TRUE; otherwise, it returns FALSE.

Examples

The following example creates two Rect objects, determines whether the second Rect object is inside the first Rect object, and then draws the two rectangles.


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

   // Create two rect objects.
   Rect rect1(50, 50, 200, 100);
   Rect rect2(50, 80, 100, 50); 

   // Determine whether rect2 is inside rect1.
   if(rect1.Contains(rect2))
   {
      // rect1 contains rect2.
   }
   // Draw the two rectangles.
   Pen pen(Color(255, 0, 0, 255));
   graphics.DrawRectangle(&pen, rect1);
   graphics.DrawRectangle(&pen, rect2);
}

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

Rect
Contains Methods
Intersect Methods
IntersectsWith
RectF
Using a Pen to Draw Lines and Rectangles
Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show: