Application.OnMinimize
OnRestore
OnActivate
OnDeactivate

解决方案 »

  1.   

    判断程序状态:
      if Form = Application.MainForm then begin
      if IsIconic(Application.Handle) then begin
      Reg File.Write Integer(Sect Name,'WindowState',
      Integer(wsMinimized));
      end;
      end;
      end;
      RegFile.Free;
      end;
      

  2.   

    newwen兄,怎么在这些事件里面写代码呢?
      

  3.   

    截获 WM_SYSCOMMAND消息,看窗体是否处于最小化状态 
    type 
      TForm1 = class(TForm) 
      private 
         procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMM 
    AND; 
      //... 
      end; implementation {$R *.DFM} 
    procedure TForm1.WMSysCommand(var Message:TMessage); 
    begin 
      if Message.WParam = SC_ICON then  //最小化了 
      begin 
      //... 
      end 
      else 
        inherited; 
    end;
      

  4.   

    直接判断是否点了窗体非客户区的最小化按钮如下: 
    type 
      TForm1 = class(TForm) 
      private 
        procedure Minimize(var mess:TWMNCLBUTTONDOWN);message WM_NCLBUTTON 
    DOWN; 
      //... 
      end; implementation {$R *.DFM} 
    procedure TForm1.Minimize(var mess:TWMNCLBUTTONDOWN); 
    begin 
        if mess.hittest=htreduce then  //htreduce表示是否按了最小化按钮 
        begin 
        //Form1.hide; ... 
        end 
        else 
            inherited; 
    end; 
      

  5.   

    呵呵,我用  if IsIconic(application.handle) then
        AState := 'iconic'
      else
        begin
          if application.active then
            AState := 'active'
          else
            AState := 'unactive'
        end;
    方法知道了状态。但是,
    当我用下面的方法来恢复的时候,却出了问题。假如是最小化状态或者active状态都没问题,但是‘deactive’,即被其它窗口覆盖的情况,restore却会跳到最上面来!而我希望是回到他原来的状态。
      if AState<>'iconic' then
        begin
          //showwindow(application.Handle,sw_hide);
          application.minimize;
          application.Restore;
        end;