private
    procedure WMCLOSE(var Msg: TMessage); message WM_CLOSE;
procedure TForm1.WMCLOSE(var Msg: TMessage);
begin
  if Msg.WParam = 0 then
    //WindowState := WSMinimized //最小化
    Application.Minimize
  else
    inherited;//关闭窗体end;
=========
这是前面帖子提到的方法,可我用了还是不行

解决方案 »

  1.   

    procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      if (Not iClose) then
      begin
        {
           iClose是个变量,可以通过它来控制是否关闭。
        }
        CanClose := False;
        Application.Minimize;
        visible := False;
      end;
    end;或者:
    procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      CanClose := False;
      Application.Minimize;
      visible := False;
    end;
      

  2.   

    看清楚了,我说了iClose是个变量,你点击另一个按钮的时候,可以让iClose = True.默认是 False。
      

  3.   

    覆盖 Form 的
        procedure WndProc(var Message:TMessage); override;procedure TForm1.WndProc(var Message:TMessage);
    begin
      if Message.Msg = WM_CLOSE then
      begin
        self.WindowState := wsMinimized
      end
      else
        inherited;end;