LCL: Implement a platform independent RectInRegion. Code presented at forum by vcunha.

git-svn-id: trunk@39156 -
This commit is contained in:
juha 2012-10-23 20:01:18 +00:00
parent 7da6d64aa2
commit ad5eed1a72
2 changed files with 19 additions and 1 deletions

View File

@ -1499,6 +1499,24 @@ begin
);
end;
// This is found in Windows API but can be implemented in platform independent way.
function RectInRegion(RGN: HRGN; ARect: TRect): Boolean;
var
RectRgn, EmptyRgn: HRGN;
begin
RectRgn := CreateRectRgnIndirect(ARect);
try
EmptyRgn := CreateEmptyRegion;
try
Result := CombineRgn(EmptyRgn, RectRgn, RGN, RGN_AND) <> NULLREGION;
finally
DeleteObject(EmptyRgn);
end;
finally
DeleteObject(RectRgn);
end;
end;
{------------------------------------------------------------------------------
Function: RGB
Params: R: Red color

View File

@ -336,6 +336,7 @@ function OffsetRect(var Rect: TRect; dx,dy: Integer): Boolean; inline;
function PtInRect(const Rect : TRect; const Point : TPoint) : Boolean; inline;
function PointToSmallPoint(const P : TPoint) : TSmallPoint; inline;
function RectInRegion(RGN: HRGN; ARect: TRect): Boolean;
function RGB(R, G, B : Byte) : TColorRef; inline;
function ScrollWindow(hWnd: HWND; XAmount, YAmount: Integer; Rect, ClipRect: PRect): Boolean; inline;
@ -350,7 +351,6 @@ function SubtractRect(out lprcDst: TRect; const lprcSrc1, lprcSrc2: TRect): Bool
function UnionRect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; //pbd
//##apiwiz##epi## // Do not remove