zoukankan      html  css  js  c++  java
  • parent 与owner的含义区别及举例

    parent即 养父
    是指拥有该组件的父类,即parent组件必定是一个窗口控制组件(Windowed control) 由于组件就是容纳该组件的父类,因此当父类移动时,附着其内的组件也会移动.
     Object TreeVIew 里表示的就是这种关系.
     1unit Unit1;
     2
     3interface
     4
     5uses
     6  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
     7  Dialogs, StdCtrls;
     8
     9type
    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
    27var
    28  Form1: TForm1;
    29
    30implementation
    31
    32uses Unit2;
    33
    34VAR
    35  PB: boolean;
    36{$R *.dfm}
    37
    38procedure TForm1.Button5Click(Sender: TObject);
    39begin
    40Form2.show
    41end;
    42
    43procedure TForm1.Button3Click(Sender: TObject);
    44begin
    45GroupBox1.Top := GroupBox1.Top - 10;
    46end;
    47
    48procedure TForm1.Button4Click(Sender: TObject);
    49begin
    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;
    60end;
    61
    62procedure TForm1.FormCreate(Sender: TObject);
    63begin
    64Pb :=  false;
    65end;
    66
    67end.
    68
    69

    Owner  生父 
     何谓Owner?就组件而言 , Owner是指作为其他组件的Owner的父组件,在负责自身 析构时,一起析构它所拥有的其下所Own的组件,也就是于此时释放它自己与它所拥有 组件所占的内存.
     1unit Unit1;
     2
     3interface
     4
     5uses
     6  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
     7  Dialogs, StdCtrls;
     8
     9type
    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
    21var
    22  Form1: TForm1;
    23
    24implementation
    25uses
    26 unit2;
    27{$R *.dfm}
    28
    29procedure TForm1.Button2Click(Sender: TObject);
    30begin
    31Form2.show
    32end;
    33
    34end.
    35
    36

  • 相关阅读:
    Java实现 洛谷 P1423 小玉在游泳
    Java设置session超时(失效)的时间
    How Tomcat works — 八、tomcat中的session管理
    三种常用的MySQL建表语句
    mysql和oracle的区别(功能性能、选择、使用它们时的sql等对比)
    oracle 基础表 mysql版
    oracle员工表和部门表基本操作
    Oracle
    java生成6位随机数
    用Ajax图片上传、预览、修改图片
  • 原文地址:https://www.cnblogs.com/dreamszx/p/1572004.html
Copyright © 2011-2022 走看看