First of all I had to fix your PointInRect function. You were comparing Pt.X against R.Top. Also, use the const directive so you are not passing the record by value.

Secondly, I would make an overloaded PointInRect() so you are not creating new TPoint instances all the time just to pass to PointInRect() from RectInRect().

[pascal]function PointInRect(const Pt: TPoint; const R: TRect) : Boolean; overload;
begin
Result := (Pt.X >= R.Left) and (Pt.X <R>= R.Top) and (Pt.Y <R>= R.Left) and (X <R>= R.Top) and (Y <= R.Bottom);
end;[/pascal]

There was another version of PointInRect() in that code that took X, Y: Single instead of const Pt: TPoint, but the forum software is refusing to show it. :evil:

Also, you should be able to get away with just four of the conditions in RectInRect(). I think you will find that it would not get into the second four at all due to short-circuit evaluation.

[pascal]function RectInRect(const R1: TRect; const R2 :TRect): Boolean;
begin
Result := PtInRect(R1.Left, R1.Top, R2) or
PtInRect(R1.Right, R1.Bottom, R2) or
PtInRect(R1.Left, R1.Bottom, R2) or
PtInRect(R1.Right, R1.Top, R2);
end;[/pascal]