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
Point Generates a TPoint value from X and Y values
PointsEqual Compares two TPoint values for equality
PtInRect Tests to see if a point lies within a rectangle
Rect Create a TRect value from 2 points or 4 coordinates
TPoint Holds X and Y integer values
TRect Holds rectangle coordinate values
 Author links

 Buy Website Traffic at

 Buy Proxies at
 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 2002 - 2016. All rights reserved.  |  Home Page