try Form2.showModal; except showmessage('打开失败!'); end
CSDN里真的没兄弟会的帮帮忙吗?
for i:=0 to Screen.FormCount-1 do begin if screen.form[i].classtype=Tform2 then showmessage('已经存在form2.'); end;
if not Assigned(Form2) then Form2:=TForm2.Create(Application); Form2.Show;
要是ShowModal的话就没必要再去判断了。
同意楼上 if Form2 = nil then Form2 := TForm2.Create(Application); Form2.Show;
showmodal是程序暂停执行,所以呢,在关掉这个窗口前,你是不可能再打开的
if form2<>nil then Form2:=Tform2.create(application); Form2.ShowModal;From2的OnClose事件中加上如下代码 Action:=caFree; Form2:=nil;
for i:=0 to Screen.FormCount-1 do begin if screen.form[i].classtype=Tform2 then showmessage('已经存在form2.'); end; 这个方法不错!!
var i: Integer; SubForm: TSubForm; begin for i:=0 to Screen.FormCount-1 do if Screen.Forms[i].classtype=TSubForm then break; if i = Screen.FormCount then SubForm := TSubForm.Create(Application); SubForm.Show; end;这个肯定行
Form2.showModal;
except
showmessage('打开失败!');
end
begin
if screen.form[i].classtype=Tform2 then showmessage('已经存在form2.');
end;
Form2:=TForm2.Create(Application);
Form2.Show;
Form2 := TForm2.Create(Application);
Form2.Show;
Form2:=Tform2.create(application);
Form2.ShowModal;From2的OnClose事件中加上如下代码
Action:=caFree;
Form2:=nil;
begin
if screen.form[i].classtype=Tform2 then showmessage('已经存在form2.');
end;
这个方法不错!!
i: Integer;
SubForm: TSubForm;
begin
for i:=0 to Screen.FormCount-1 do
if Screen.Forms[i].classtype=TSubForm then break;
if i = Screen.FormCount then
SubForm := TSubForm.Create(Application);
SubForm.Show;
end;这个肯定行