Delphi實例演示Rect、Bounds生成TRect的區別。本站提示廣大學習愛好者:(Delphi實例演示Rect、Bounds生成TRect的區別)文章只能為提供參考,不一定能成為您想要的結果。以下是Delphi實例演示Rect、Bounds生成TRect的區別正文
本文以實例演示Rect、Bounds生成TRect的區別,實例代碼如下:
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); {參數3、4 是一個點} 2: Button1.BoundsRect := Bounds(50,50,100,80);{參數3、4 辨別是寬度與高度} end; end; end.
最終完成效果圖如下: