比如最小化时我要把窗体隐藏,请高人指点

解决方案 »

  1.   

    捕获最小化的消息就行了。:)procedure TForm1.MinWindow(var Msg: Tmessage);
    begin
      if msg.WParam=SC_MINIMIZE then
        showmessage('要最小化了');
       inherited; 
    end;
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure OnMinDo(Sender: TObject);
      end;var
      Form1: TForm1;implementation{$R *.DFM}
    procedure TForm1.OnMinDo(Sender: TObject);
    begin
      ShowMessage('最小化了!');
      //<------最小化要做的事情
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Application.OnMinimize := OnMinDo;
    end;end.
      

  3.   

    //还要一招
    CloseWindow(handle);
    //handle可以是你指定的窗体句柄。
    //不过最好是一楼的,我喜欢用Windows消息处理。
      

  4.   

    补充一点、函数声明一定要这样;否则不行。
    呵呵procedure MinWindow(var Msg: Tmessage);message WM_SYSCOMMAND;