if not Assigned(Modeless) then
Assigned()什么意思!
最佳答案
assigned 是用来判断某一指针(pointer)或过程引用是否为nil(空),如果为空则返回假(fal)。
用法示例(防止窗体被实例化多次):
unit Unit1;
interface
us
Windows, Messages, SysUtils, Variants, Class, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
us Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Not assigned(form2)) then
begin
form2:=Tform2.Create(Self);
end;
form2.show;
end;
end.
-----------------------
unit Unit2;
interface
us
Windows, Messages, SysUtils, Variants, Class, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormClo(Sender: TObject; var Action: TCloAction); private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormClo(Sender: TObject; var Action: TCloAction); begin
Action:=caFree;
form2:=nil; //这句比较重要,窗体被释放时,窗体变量并不会自动变空end;
end.