UnionRect (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code example illustrates the usage of the UnionRect function.

Code

uses
  System.SysUtils, System.Types;
var
  aRect1, aRect2, resultRect : TRect;
begin
  aRect1 := Rect(4,8,25,36);
  aRect2 := Rect(51,48,30,44);
  resultRect := UnionRect(aRect1, aRect2);
  if (resultRect.Left <= 0) and (resultRect.Top <= 0) and (resultRect.Bottom <= 0) and (resultRect.Right <= 0) then
    WriteLn('The union of aRect1 and aRect2 returned false')
  else
    WriteLn(resultRect.Left,' ',resultRect.Top,' ',resultRect.Right,' ', resultrect.Bottom);
//-------------------------------------------------------------------------------------------------------------------
  { Other possible way to do it is by using the overloaded function of UnionRect: }
   if UnionRect(resultRect,aRect1, aRect2) then
     WriteLn('An union between aRect1 and aRect2 exists!')
   else
     WriteLn('The width or height of the resulting triangle is less than or equal to 0!');
end;

Uses