procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin if MessageDlg('Close application ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then Action := caFree else Action := caNone; end; 定义子窗体的onclose事件
没有错的 在你的formclose事件中 写上 action:=cafree就可以了
窗体Close事件写: Action :=CaFree
这个我以前碰到过,这样可以实现: 在某一事件中,指定社会窗体的Action:=caFree;
FreeAndNil(Self);申明一点,只使用Action属性最后实际上是保留下一个野指针!
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end;procedure TForm2.FormDestroy(Sender: TObject); begin Form2:=nil; end;
我想大家没看清楚我的问题,我是想在主窗体上做一个按钮,关闭当前打开的所有MDI子窗体。
var i:integer begin for i:=0 to MDIChildCount do MDIChildren[i].Close; end;
ACTION:=CAFREE
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
定义子窗体的onclose事件
在你的formclose事件中 写上
action:=cafree就可以了
Action :=CaFree
在某一事件中,指定社会窗体的Action:=caFree;
begin
Action:=caFree;
end;procedure TForm2.FormDestroy(Sender: TObject);
begin
Form2:=nil;
end;
i:integer
begin
for i:=0 to MDIChildCount do
MDIChildren[i].Close;
end;