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(INT, INT) method

Applies to: desktop apps only

The Rect::Contains method determines whether the point ( x, y) is inside this rectangle.

Syntax

BOOL Contains(
  [in]  INT x,
  [in]  INT y
);

Parameters

x [in]

Type: INT

Integer that specifies the x-coordinate of the point to be tested.

y [in]

Type: INT

Integer that specifies the y-coordinate of the point to be tested.

Return value

Type:

Type: BOOL

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

Examples

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


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

   // Create a rect object.
   Rect rect(50, 50, 200, 100);

   // Determine whether a specified point is inside the rectangle.
   if(rect.Contains(80, 90))
   {
      // The point (80, 90) is inside the rectangle.
   }
   // Draw the rectangle and the point (80, 90).
   Pen pen(Color(255, 0, 0, 255));
   graphics.DrawRectangle(&pen, rect);
   graphics.DrawRectangle(&pen, 80, 90, 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:
© 2014 Microsoft