Share via


CRect::PtInRect

Determina si el punto especificado está dentro de CRect.

BOOL PtInRect( 
   POINT point  
) const throw( );

Parámetros

  • point
    contiene una estructura de puntos o un objeto de CPoint .

Valor devuelto

Distinto de cero si el punto está dentro de CRect; si no 0.

Comentarios

Un punto está dentro de CRect si está en el lado izquierdo o superior o está dentro de los cuatro lados.Un punto a la derecha el lado o inferior es CRectfuera.

[!NOTA]

El rectángulo debe ser normalizado o esta función puede producir un error.Puede llamar a NormalizeRect para normalizar el rectángulo antes de llamar a esta función.

Ejemplo

CRect rect(5, 5, 100, 100);
CPoint pt1(35, 50);
CPoint pt2(125, 298);

// this is true, because pt1 is inside the rectangle
ASSERT(rect.PtInRect(pt1));

// this is NOT true, because pt2 is outside the rectangle
ASSERT(!rect.PtInRect(pt2));

// note that the right and the bottom aren't inside
ASSERT(!rect.PtInRect(CPoint(35, 100)));
ASSERT(!rect.PtInRect(CPoint(100, 98)));

// but the top and the left are inside
ASSERT(rect.PtInRect(CPoint(5, 65)));
ASSERT(rect.PtInRect(CPoint(88, 5)));

// and that PtInRect() works against a POINT, too
POINT pt;
pt.x = 35;
pt.y = 50;
ASSERT(rect.PtInRect(pt));   

Requisitos

encabezado: atltypes.h

Vea también

Referencia

Clase de CRect

Gráfico de jerarquía

CRect::NormalizeRect

PtInRect