delphi传递与复制对象(DELPHI5从入门到精通75页)
var
Button2:Tbutton;
begin
Button2 := button1;
这段代码没有建立一个新对象,而是建立了对内存中同一个对象的引用。内存中只有1个对象,而Button1,Button2变量都引用它。如果将对象作为参数传递给函数也是一样,没有建立新对象,而是在代码的两个不同位置引用了同一个对象。
我们可以查询组件的类(sender.classtype),然后使用类引用建立该类型的新对象。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
ScrollBox1: TScrollBox;
Label1: TLabel;
CheckBox1: TCheckBox;
Label2: TLabel;
Button2: TButton;
Edit1: TEdit;
BitBtn1: TBitBtn;
SpeedButton1: TSpeedButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure ClickComp(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sende
- 关于delphi制作安装文件的问题!急,急,急!
- 请教关于Delphi 开发使用报表
- Delphi全局变量带来的问题
- Delphi中出现小问题及处理
- 有关 delphi7读取 excel 报错EoleException with message '未找到提供程序,该程序可能未能正确安装' 解决方式
- delphi7+ado+sqlsever2008数据库软件发布打包些什么东,还有人用delphi 么,求好友
- 【逆向】Delphi程序逆向之熊猫烧香病毒分析
- delphi下的编程
- Delphi结构类型包含String字符串使用需要注意的地方
- 第一个Delphi7.0 图形界面程序:显示唐诗静夜思
- Delphi里面的TCriticalSection对象的用法(如何使用锁)
- 在DELPHI程序中自动设置ODBC数据源
- delphi下ado连接vfp数据表的常用方法
- Delphi下DLL编程知识(转)
- Delphi 7中的四种消息框
- Delphi备忘录——基本语句
- 几个获取Windows系统信息的Delphi程序
- Delphi中Format与FormatDateTime函数详解
- 从Delphi开发环境的变迁说起
- Delphi多条件模糊查询的实现