如果拦截窗体的最小化,最大化,关闭等事件,用拦截win消息的方法.

解决方案 »

  1.   

    直接替换winproc函数
    或者使用消息函数(后面带有message XXXXX)
      

  2.   

    覆盖Wndproc过程,进行消息过滤
    if msg.message=消息名称 then exit;
    inherited;
      

  3.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Self.WindowProc := Proc;
    end;procedure TForm1.Proc(var Msg: TMessage);
    begin
      if Msg.Msg  = WM_SYSCOMMAND then
      begin
        if Msg.WParam=SC_MAXIMIZE then
          Caption := '最大化了'
        else if Msg.WParam=SC_MINIMIZE then
          Caption := '最小化了';
      end;
      WndProc(Msg);
    end;