在MDI主窗体中只能显示一个子窗体 :
procedure TForm1.MainMenu1Change(Sender: TObject; Source: TMenuItem;
Rebuild: Boolean);
var
childcount:integer;
begin
if form1.MDIChildCount >0 then
begin
for childcount:=0 to form1.MDIChildCount do
form1.MDIChildren[childcount].Close ;
end;
end;
在子窗体的onclose事件中设置:
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
form3:=nil;
end;