1、新建 FM(HD) 工程, 先添加 TLine(默认名称是 Line1);
2、在 Line1 选择状态下添加 Button1;
3、取消选择后添加 Button2
此时, Button1.Parent 是 Line1; Button2.Parent 是窗体.
unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Objects; type TForm1 = class(TForm) Line1: TLine; Button1: TButton; Button2: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); begin Button2.OnClick := Button1.OnClick; { TLine } end; procedure TForm1.Button1Click(Sender: TObject); begin Caption := TButton(Sender).Parent.ClassName; { TForm1; 现在的窗体没有 Text 属性了 } Line1.Position.X := Line1.Position.X + 10; { Btuuon1 会随同移动 } end; end.