2,497
社区成员
发帖
与我相关
我的任务
分享
{只能打开一个mdi窗体}
try
if application.MainForm.MDIChildCount>0 then{判断主窗体里面的子窗体个数是否大于0}
activemdichild.Close;
finally
TForm2.Create(Self);{这是子窗体,MDIChild窗体自己创建自己显示,不用Show}
end;
//======================================================
//findfrm函數用來查找子窗體,若當前打開則在最前面顯示,否則打開
//======================================================
Function findfrm(frmname:String): boolean;
var i:integer;
begin
result:=false;
for i:=0 to screen.FormCount-1 do
if uppercase(screen.Forms[i].Name)=uppercase(frmname) then
begin
screen.Forms[i].BringToFront;
result:=true;
break;
end
else
result:=false;
end;
//調用函數
procedure Tmainfrm.N5Click(Sender: TObject);
begin
if not findfrm('auto_workfrm') then
begin
auto_workfrm:=tauto_workfrm.Create(self);
auto_workfrm.Show;
end
else
auto_workfrm.BringToFront;
end;