2011年1月7日

Delphi的对象注销方法Destroy和free的区别

摘要: Delphi的对象注销方法Destroy和free的区别当您使用完对象后,您应该及时撤销它,以便把这个对象占用的内存释放出来。您可以通过调用一个注销方法来撤销您的对象,它会释放分配给这个对象的内存。 Delphi的注销方法有两个:Destroy和Free。Delphi建议使用Free,因为它比Destroy更为安全,同时调用Free会生成效率更高的代码。 您可以用下列的语句释放用完的Employee对象: Employee.Free; 和Create方法一样,Free方法也是TEmployee从TObject中继承过来的。把您的注销放在try…finally程序模块的finally部分,而把对 阅读全文

posted @ 2011-01-07 16:54 jshchg 阅读(1343) 评论(0) 推荐(0)

两种类的声明方法

摘要: 转载至:两种类的声明方法说明:Delphi的类声明有两种方法,一种是继承了Delphi的内建类的声明,另一种则是完全自定义的类声明。这两种类的区别不仅在于声明程序的不同,还会影响到对象实体的内存管理。1unitUnit1;23interface45uses6Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,7Dialogs,StdCtrls,Buttons;89type10TForm1=class(TForm)11btn1:TBitBtn;12btn2:TBitBtn;13procedurebtn1Click( 阅读全文

posted @ 2011-01-07 16:19 jshchg 阅读(447) 评论(0) 推荐(0)

delphi中 formclose的事件 action:=cafree form:=nil分别是什么意思?

摘要: MDI子窗体关闭时用到的(以下摘自Delphi的帮助)caNone The form is not allowed to close, so nothing happens.caHide The form is not closed, but just hidden. Your application can still access a hidden form.caFree The form is closed and all allocated memory for the form is freed.caMinimize The form is minimized, rather tha 阅读全文

posted @ 2011-01-07 15:57 jshchg 阅读(4710) 评论(0) 推荐(0)

assigned(对象名)判断对象有没有被实例化?

摘要: assigned 是用来判断某一指针(pointer)或过程引用是否为nil(空),如果为空则返回假(false)。用法示例(防止窗体被实例化多次):unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private dec 阅读全文

posted @ 2011-01-07 15:56 jshchg 阅读(679) 评论(0) 推荐(0)

导航