给个通用过程,不管是不是MDI窗体都行
procedure OpenForm(FormClass: TFormClass; var AForm;
AOwner:TComponent=nil);
//根据窗口类名建立窗口,如果窗口存在则只激活它
var
i: integer;
Child:TForm;
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms.ClassType=FormClass then
begin
Child:=Screen.Forms;
if Child.WindowState=wsMinimized then
Child.WindowState:=wsNormal;
Child.BringToFront;
Child.Setfocus;
TForm(AForm):=Child;
exit;
end;
Child:=TForm(FormClass.NewInstance);
TForm(AForm):=Child;
if not assigned(aowner) then aowner:=application;
Child.Create(AOwner);
end;
建立用
OpenForm(Tydcx_frm,ydcx_frm,self);
窗口关闭还是
procedure Tydcx_frm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
end;