XE 画矩形实现拖拉改变大小(属性)
2015-11-02 16:15
357 查看
实现原理:
1.拖一个rectangle控件,Align属性为TOP
2.拖一个Split控件,Align为Top
3.拖Rectangle,Align为Bottom
4.拖Split,Align为Bottom
5.左边、右边依次类推,
6.最后拖一个Rectangle,Align为Client,Stroke属性中的Color为red。
具体代码:
这里充分理解了属性,见证了属性的强大,好好学习,再接再厉。
1.拖一个rectangle控件,Align属性为TOP
2.拖一个Split控件,Align为Top
3.拖Rectangle,Align为Bottom
4.拖Split,Align为Bottom
5.左边、右边依次类推,
6.最后拖一个Rectangle,Align为Client,Stroke属性中的Color为red。
具体代码:
unit UnitCheckIPN; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Objects, FMX.Controls.Presentation; type TForm2 = class(TForm) RT: TRectangle; //RectTop ST: TSplitter; RL: TRectangle; SL: TSplitter; RB: TRectangle; SB: TSplitter; RR: TRectangle; SR: TSplitter; Rect: TRectangle; Image1: TImage; Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } procedure SetRect(s:String); function GetRC: String; // 获取 获取当前矩形的位置 procedure SetRC(const Value: String); // 设置 给定x,y,w,h 矩形自动改变位置 public { Public declarations } property RC: String read GetRC write SetRC; // 将矩形的值设为属性,读为获取rect的(x,y,width, height) 写时为设置矩形的x,y,w,h end; var Form2: TForm2; implementation {$R *.fmx} procedure TForm2.Button1Click(Sender: TObject); begin RC:='103,128,301,203'; // end; procedure TForm2.Button2Click(Sender: TObject); begin ShowMessage(RC); // end; procedure TForm2.Button3Click(Sender: TObject); begin RC:='103,128,394,203'; end; function TForm2.GetRC: String; var x,y,w,h : Single; begin result:=''; y:=RT.Height+ST.Height; h:=Image1.Height - RT.Height - ST.Height - RB.Height - SB.Height; x:=RL.Width+SL.Width; w:=Image1.Width-RL.Width-SL.Width-RR.Width-SR.Width; result:=x.ToString()+','+y.ToString()+','+w.ToString()+','+h.ToString(); end; procedure TForm2.SetRC(const Value: String); var ss: TStringList; x,y,w,h: Integer; begin ss:=TStringList.Create; ss.CommaText:=Value; x:=ss[0].ToInteger(); y:=ss[1].ToInteger(); w:=ss[2].ToInteger(); h:=ss[3].ToInteger(); ss.Free; RT.Height:=y-ST.Height; RB.Height:=Image1.Height-(RT.Height + ST.Height + h + SB.Height); RL.Width:=x-SL.Width; RR.Width:=Image1.Width-(RL.Width+SL.Width+w+SR.Width); end; procedure TForm2.SetRect(s: String); var ss: TStringList; x,y,w,h: Integer; begin ss:=TStringList.Create; ss.CommaText:=s; x:=ss[0].ToInteger(); y:=ss[1].ToInteger(); w:=ss[2].ToInteger(); h:=ss[3].ToInteger(); ss.Free; RT.Height:=y-ST.Height; RB.Height:=Image1.Height-(RT.Height + ST.Height + h + SB.Height); RL.Width:=x-SL.Width; RR.Width:=Image1.Width-(RL.Width+SL.Width+w+SR.Width); end; end.
这里充分理解了属性,见证了属性的强大,好好学习,再接再厉。
相关文章推荐
- java抓取快递100信息接口
- Lua Math库的一些功能
- 第9周 项目1 - 猴子选大王(数组版)
- 将人力资源中的员工编号由自动生成设置为手动编号
- UIActivityIndicatorView的使用方法详细
- 计算灰度共生矩阵GLCM
- (一)自定义ViewGroup绘制出菜单
- 关于Java的File.separator
- 第十周项目一~~二叉树算法库
- Windows核心编程:内核对象
- 使用Qt Quick实现顶部横幅(Banner)效果
- FragMent,ViewPager 实现每个页面都请求网络。
- leetcode-Kth Smallest Element in a BST
- UIAlertView的使用方法详细
- SVM Light 使用
- python 爬虫的简单示例
- Samy 蠕虫代码
- Redis系列-存储篇hash主要操作函数小结
- 解决Xcode 7 http无法使用的问题
- astercc开源电话计费系统