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(const Point&) method

Applies to: desktop apps only

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

Syntax

BOOL Contains(
  [in]  const Point& pt
);

Parameters

pt [in]

Type: const Point&

Reference to a point to be tested.

Return value

Type:

Type: BOOL

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

Examples

The following example creates a Rect object and a Point object. The code then determines whether the point is inside the rectangle and then draws the rectangle and the point.


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

   Rect rect(50, 50, 200, 100);
   Point point(80, 90);

   if(rect.Contains(point))
   {
      // The point is inside the rectangle.
   }
   // Draw the rectangle and the point.
   Pen pen(Color(255, 0, 0, 255));
   graphics.DrawRectangle(&pen, rect);
   graphics.DrawRectangle(&pen, point.X, point.Y, 1, 1);
}

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
Point
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: