This article demonstrates the difference between rect and bounds generation Trect with an example code as follows:
unitUnit1;
Interface
uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Button1:tbutton;
Radiogroup1:tradiogroup;
Procedure Radiogroup1click (sender:tobject);
Procedure Formcreate (sender:tobject);
End;
var
form1:tform1;
Implementation
{$R *.DFM}
var
r:trect;
Procedure Tform1.formcreate (sender:tobject);
Begin
RadioGroup1.Items.CommaText: = ' undo,rect,bounds ';
R: = Button1.boundsrect;
End;
Procedure Tform1.radiogroup1click (sender:tobject);
Begin case
Radiogroup1.itemindex of
0:button1.boundsrect: = R;
1:button1.boundsrect: = Rect (50,50,100,80); {Parameter 3, 4 is a point}
2:button1.boundsrect: = Bounds (50,50,100,80); {Parameters 3, 4 are width and height}
End;
End;
End.
The final implementation of the effect diagram is as follows: