Udostępnij za pośrednictwem


CRect::PtInRect

Określa, czy określony punkt leży w CRect.

BOOL PtInRect( 
   POINT point  
) const throw( );

Parametry

Wartość zwracana

Niezerowa, jeśli punkt leży w CRect; 0 inaczej.

Uwagi

Punkt jest w CRect on leży po stronie lewej lub górnej lub jest w ramach wszystkich czterech stron.Punkt po prawej lub dolnej stronie jest poza CRect.

[!UWAGA]

Prostokąta musi być znormalizowane lub tej funkcji może się nie powieść.Można wywołać NormalizeRect do znormalizowania prostokąta przed wywołaniem tej funkcji.

Przykład

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));   

Wymagania

Nagłówek: atltypes.h

Zobacz też

Informacje

Klasa CRect

Wykres hierarchii

CRect::NormalizeRect

PtInRect