是指拥有该组件的父类,即parent组件必定是一个窗口控制组件(Windowed control) 由于组件就是容纳该组件的父类,因此当父类移动时,附着其内的组件也会移动.
Object TreeVIew 里表示的就是这种关系.
1
unit Unit1;
2
3
interface
4
5
uses
6
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
Dialogs, StdCtrls;
8
9
type
10
TForm1 = class(TForm)
11
GroupBox1: TGroupBox;
12
Button1: TButton;
13
Button2: TButton;
14
Button3: TButton;
15
Button4: TButton;
16
Button5: TButton;
17
procedure Button5Click(Sender: TObject);
18
procedure Button3Click(Sender: TObject);
19
procedure Button4Click(Sender: TObject);
20
procedure FormCreate(Sender: TObject);
21
private
22
{ Private declarations }
23
public
24
{ Public declarations }
25
end;
26
27
var
28
Form1: TForm1;
29
30
implementation
31
32
uses Unit2;
33
34
VAR
35
PB: boolean;
36
{$R *.dfm}
37
38
procedure TForm1.Button5Click(Sender: TObject);
39
begin
40
Form2.show
41
end;
42
43
procedure TForm1.Button3Click(Sender: TObject);
44
begin
45
GroupBox1.Top := GroupBox1.Top - 10;
46
end;
47
48
procedure TForm1.Button4Click(Sender: TObject);
49
begin
50
if PB then
51
BEGIN
52
Button2.Parent := Form2;
53
PB := false;
54
END
55
else
56
BEGIN
57
Button2.Parent := Form1.GroupBox1;
58
PB := true;
59
END;
60
end;
61
62
procedure TForm1.FormCreate(Sender: TObject);
63
begin
64
Pb := false;
65
end;
66
67
end.
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Owner 生父
何谓Owner?就组件而言 , Owner是指作为其他组件的Owner的父组件,在负责自身 析构时,一起析构它所拥有的其下所Own的组件,也就是于此时释放它自己与它所拥有 组件所占的内存.
1
unit Unit1;
2
3
interface
4
5
uses
6
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
Dialogs, StdCtrls;
8
9
type
10
TForm1 = class(TForm)
11
Edit1: TEdit;
12
Button1: TButton;
13
Button2: TButton;
14
procedure Button2Click(Sender: TObject);
15
private
16
{ Private declarations }
17
public
18
{ Public declarations }
19
end;
20
21
var
22
Form1: TForm1;
23
24
implementation
25
uses
26
unit2;
27
{$R *.dfm}
28
29
procedure TForm1.Button2Click(Sender: TObject);
30
begin
31
Form2.show
32
end;
33
34
end.
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36