怎样自定义 最大化, 最小化,消息?

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
    begin
      case Message.CmdType of
        SC_MAXIMIZE: ShowMessage('最大化');
        SC_MINIMIZE: ShowMessage('最小化');
      end;
      inherited;
    end;end.
      

  2.   

    ApplicationEvents控件就有最小化事件,是OnMinimize,不过楼上的办法最好!
      

  3.   

    Application.OnMinimize是什么?它和窗体的最小化其实没关系,只有主窗体的最小化才会触发该事件,其中机妙,从VCL中可得到答案procedure TCustomForm.WMSysCommand(var Message: TWMSysCommand);
    begin
      with Message do
      begin
        if (CmdType and $FFF0 = SC_MINIMIZE) and (Application.MainForm = Self) then
          Application.WndProc(TMessage(Message))//就是这里,明白?
        else if (CmdType and $FFF0 <> SC_MOVE) or (csDesigning in ComponentState) or
          (Align = alNone) or (WindowState = wsMinimized) then
          inherited;
        if ((CmdType and $FFF0 = SC_MINIMIZE) or (CmdType and $FFF0 = SC_RESTORE)) and
          not (csDesigning in ComponentState) and (Align <> alNone) then
          RequestAlign;
      end;
    end;如果不是MainForm,它们之间没关系
      

  4.   

    Application的方法Minimize才和最小化有关系,OnMinimize是在最小化这个动作发生的时候触发的一个事件而已!!!!