如何关闭一个MDI子窗体,即把所有的MDI子窗体都关掉,如何做?

解决方案 »

  1.   

    在ONCLOSE 事件了 
    ACTION:=CAFREE
      

  2.   

    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事件
      

  3.   

    没有错的
    在你的formclose事件中 写上
    action:=cafree就可以了
      

  4.   

    窗体Close事件写:
    Action :=CaFree
      

  5.   

    这个我以前碰到过,这样可以实现:
    在某一事件中,指定社会窗体的Action:=caFree;
      

  6.   

    FreeAndNil(Self);申明一点,只使用Action属性最后实际上是保留下一个野指针!
      

  7.   

    procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action:=caFree;
    end;procedure TForm2.FormDestroy(Sender: TObject);
    begin
      Form2:=nil;
    end;
      

  8.   

    我想大家没看清楚我的问题,我是想在主窗体上做一个按钮,关闭当前打开的所有MDI子窗体。
      

  9.   

    var
      i:integer
    begin
      for i:=0 to MDIChildCount do
        MDIChildren[i].Close;
    end;