在多个窗体的程序里(不是MDI)
为什么我窗体CLOSE的时候会把整个程序关闭呢?
而我用Release的话就没问题,但点这个窗体的八叉一样还是把整个程序给关闭了....
为什么?谁能说的明白的点?
告诉正确的方法?

解决方案 »

  1.   

    那要看你在CLOSE裏面寫了什麼,如果你寫了 application.terminated,  那肯定會關掉的
      

  2.   


    procedure TCustomForm.Close;
    var
      CloseAction: TCloseAction;
    begin
      if fsModal in FFormState then
        ModalResult := mrCancel
      else
        if CloseQuery then
        begin
          if FormStyle = fsMDIChild then
            if biMinimize in BorderIcons then
              CloseAction := caMinimize else
              CloseAction := caNone
          else
            CloseAction := caHide;
          DoClose(CloseAction);
          if CloseAction <> caNone then
            if Application.MainForm = Self then Application.Terminate//如果当前窗口为MainForm 时,将执行Application.Terminate
            else if CloseAction = caHide then Hide
            else if CloseAction = caMinimize then WindowState := wsMinimized
            else Release;
        end;
    end;