首页 > 编程 > Delphi > 正文

Delphi实例演示Rect、Bounds生成TRect的区别

2020-01-31 20:51:16
字体:
来源:转载
供稿:网友

本文以实例演示Rect、Bounds生成TRect的区别,实例代码如下:

unitUnit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ExtCtrls;typeTForm1 = class(TForm)Button1: TButton;RadioGroup1: TRadioGroup;procedure RadioGroup1Click(Sender: TObject);procedure FormCreate(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}varR: TRect;procedure TForm1.FormCreate(Sender: TObject);beginRadioGroup1.Items.CommaText := 'Undo,Rect,Bounds';R := Button1.BoundsRect;end;procedure TForm1.RadioGroup1Click(Sender: TObject);begincase RadioGroup1.ItemIndex of0: 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.

最终实现效果图如下:

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选