Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 27691, TPoint and TRect Record Helpers

by Jim Ferguson Email: Anonymous

Using Delphi record helpers to enhance TRect and TPoint without touching source code.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 11.0  to 13.0 188 downloads
Copyright: No significant restrictions

Size: 1,773 bytes
Updated on Wed, 28 Apr 2010 16:16:44 GMT
Originally uploaded on Wed, 28 Apr 2010 16:16:45 GMT
SHA1 Hash: 1E0D0210C78CD9CDB35A5F1A66CE1A95F351FF05
MD5 Hash: 3550CA262A9664B737584D4F638A4F1F

    Explore the files in this upload

This is a record helper for TRect and TPoint. These examples show ways to enhance the structures in other units to add things with

setting a rectangle's dimensions though Width and Height properties
how about a TPoint that is the TopRight and the BottomLeft, growing, moving, swapping, converting to a string. Etc.

TRect_Helper = record helper for TRect
function GetHeight: Integer; inline;
function GetWidth: Integer; inline;
procedure SetHeight(const Value: Integer); inline;
procedure SetWidth(const Value: Integer); inline;
function GetSize: TSIze;
procedure SetSize(const Value: TSIze);
function GetBottomLeft: TPoint;
function GetTopRight: TPoint;
procedure SetBottomLeft(const Value: TPoint);
procedure SetTopRight(const Value: TPoint);
function Equals(const B: TRect): Boolean; inline;
procedure Add(const Value: TRect);
procedure AssignTLWH(Left,Top,Width,Height: Integer);
procedure AssignLW(Left,Width: Integer);
procedure Grow(DX,DY: Integer);
procedure Move(DX,DY: Integer);
procedure GDIAdjust;
procedure SwapH;
procedure SwapV;
procedure CheckOrder;
function ToString: String;
procedure AlignToPoint(const APoint: TPoint; const ASize: TSize; Align: TTextAlign);
property Width: Integer read GetWidth write SetWidth;
property Height: Integer read GetHeight write SetHeight;
property Size: TSIze read GetSize write SetSize;
property TopRight: TPoint read GetTopRight write SetTopRight;
property BottomLeft: TPoint read GetBottomLeft write SetBottomLeft;

TPoint_Helper = record helper for TPoint
function Equals(const B: TPoint): Boolean; inline;
function Assign(Point: TPoint): Boolean; {$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Inc; overload; {$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Inc(Delta: Integer); overload; {$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Inc(DeltaX,DeltaY: Integer); overload; {$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Inc(Delta: TPoint); overload; {$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Dec(DeltaX,DeltaY: Integer); overload; {$IFDEF USE_INLINE}inline;{$ENDIF}
class function New(AX,AY: Integer): TPoint; static;
procedure SetZero;
function ToString: String;
function Convert(const Value: TSize): TPoint; inline;


   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04