Create a TRect value from top left and size values Classes unit
 function Bounds(const Top, Left, Width, Height Integer):TRect;
The Bounds function creates a TRect rectangle value from Top, Left coordinates, and Width, Height size values.
It provides a useful alternative to the Rect function, where you must know the bottom and right coordinates rather than the rectangle size.
Related commands
PointGenerates a TPoint value from X and Y values
PointsEqualCompares two TPoint values for equality
PtInRectTests to see if a point lies within a rectangle
RectCreate a TRect value from 2 points or 4 coordinates
TPointHolds X and Y integer values
TRectHolds rectangle coordinate values
 Download this web site as a Windows program.

Example code : Create rectangles using Rect and Bounds
  rectangle1, rectangle2 : TRect;

  // Set up the first rectangle using the Rect function
  // Note that we override the Types version of Rect.
  rectangle1 := Classes.Rect(Point(10, 60), Point(50, 80));

  // Set up an identical 2nd rectangle using the Bounds function
  rectangle2 := Bounds(10, 60, 40, 20);

  // Display the top left and bottom right coords of each rectangle
  ShowMessageFmt('Rectangle 1 coords = %d,%d,%d,%d',

  ShowMessageFmt('Rectangle 2 coords = %d,%d,%d,%d',
Show full unit code
  Rectangle 1 coords = 10,60,50,80
  Rectangle 2 coords = 10,60,50,80
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page