Quote Originally Posted by grudzio
Sly is right that RectInRect function can be reduced to four PointInRect checks.

It uses two diagonal points of the first rect and two points of second rect taken from second diagonal.
My theory was right, but my proof was wrong.

Using const in this case will help with performance because it will not be copying the records to pass by value. Since the records are not being modified within the functions, use const for the performance benefit.

Also use the PointInRect that takes two Singles and a const TRect as it will be faster than calling another function to return a TPoint by value then passing that TPoint to RectInRect.