rt,我想在打开一个子窗口时,关闭前一个子窗口,下面代码不对吗,为什么打开新窗口时,原来的没有被关闭,为什么?
function closemdifrm: Boolean;//关闭之前的子窗口
begin
with Application.MainForm do
begin
if ActiveMDIChild <> nil then
begin
if not (application.MessageBox('确认关闭当前的窗口?', '确认', mb_yesno) = idno) then
begin
ActiveMDIChild.Close;
Result := True;
end
else Result := False;
end
else Result := True;
end;
procedure Tform1.openExecute(Sender: TObject);
var child: Tfrmmdi;
begin
if not closemdifrm then
abort
else
begin
child := Tfrmmdi.Create(application);
end;
end;
function closemdifrm: Boolean;//关闭之前的子窗口
begin
with Application.MainForm do
begin
if ActiveMDIChild <> nil then
begin
if not (application.MessageBox('确认关闭当前的窗口?', '确认', mb_yesno) = idno) then
begin
ActiveMDIChild.Close;
Result := True;
end
else Result := False;
end
else Result := True;
end;
procedure Tform1.openExecute(Sender: TObject);
var child: Tfrmmdi;
begin
if not closemdifrm then
abort
else
begin
child := Tfrmmdi.Create(application);
end;
end;
var i:integer;
begin
for i:=0 to FrmMain.MDIChildCount-1 do
begin
if frmMain.MDIChildren[i].Active then
FrmMain.MDIChildren[i].Close;
end;
end;
begin
if ActiveMDIChildren<>nil then
ActiveMDIChild.Close;
end;procedure TMainForm.Item_CloseAllClick(Sender:TObject);
var i:integer
begin
for i:=MDIChildCount-1 downto 0 do
MDIChildren[i].Close
end;