Browse - Programming Tips - How can I check if a point is inside a rectangle?
Q. How can I check if a point is inside a rectangle?
A. Here's a function that does that:
// Make sure both are in the same co-ordinates
BOOL IsInside(const RECT &rect, const POINT point)
return !(point.x < rect.left || point.x > rect.right || point.y < rect.top || point.y > rect.bottom);
BOOL IsInsideAlternate(const RECT &rect, const POINT point)
return point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom);
if (IsInside(rect, point))
In MFC you can use CRect::PtInRect()