For i := 0 to Form1.MDIChildCount-1 do if Form1.MDIChildren[i].Active then FreeAndNil(form1.MDIChildren[I]);编译第三句出现: [Error] Unit1.pas(214): Constant object cannot be passed as var parameter这是什么意思?
For i := 0 to Form1.MDIChildCount-1 do if Form1.MDIChildren[i].Active then form1.MDIChildren[I].Close; 在每个MDI窗口的加入 procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end;procedure TForm1.FormDestroy(Sender: TObject); begin Form1 := nil; //注意这里 end;
呵呵, FreeAndNil 需要一个确定变量名 没必要用FreeAndNil for I := MDIChildCount-1 downto 0 do MDIChildren[I].Close; 另外在每个子窗体的OnClsoe里 Action := caFree 就OK了
For i = (Me.MdiChildren.Length - 1) To 0 Step -1
Me.MdiChildren(i).Close()
Next i
if MainForm.MDIChildren[i].Active then
MainForm.MDIChildren[i].Close;
if Form1.MDIChildren[i].Active then
FreeAndNil(form1.MDIChildren[I]);编译第三句出现:
[Error] Unit1.pas(214): Constant object cannot be passed as var parameter这是什么意思?
if Form1.MDIChildren[i].Active then
form1.MDIChildren[I].Close;
在每个MDI窗口的加入
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
Form1 := nil; //注意这里
end;
没必要用FreeAndNil
for I := MDIChildCount-1 downto 0 do
MDIChildren[I].Close;
另外在每个子窗体的OnClsoe里
Action := caFree
就OK了