TRectHeight (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use Height method to return the height of the rectangle. Height method needs to be applied only if the rectangle is normalized. A rectangle is normalized if Top < Bottom or Left < Right.

Code

uses
  System.SysUtils,
  System.Types;

var
  aRectangle : TRect;
  aValue :Integer;

begin
    aRectangle.Create(1,14,3,20);
    aRectangle.NormalizeRect();
    writeln(Format('%d %d %d %d',[aRectangle.Left,aRectangle.Top,aRectangle.Right,aRectangle.Bottom]));
    //The console will output: 1 14 3 20, representing the coordinates of the corners of aRectangle

    aValue:=aRectangle.Height;
    writeln(Format('%d',[aValue]));
    //The console will output: 6, representing the the height of aRectangle

end.

Uses