我想处理一下Application的一些事件。
我要在最小化程序是让它的按钮从任务栏消失。
还原或者最大化时在显示按钮~~我该怎么做呀~~~
我找不到合适的贴子,很多方法我都试过了~~
ApplicationEventsMinimize(Sender: TObject);
ApplicationEventsRestore(Sender: TObject);
上面两个事件我用SetWindowLong处理过,但是按钮依然还在,没有用处阿~~

解决方案 »

  1.   

    写消息处理
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TMainForm = class(TForm)
      private
        { Private declarations }
        procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
      public
        { Public declarations }
      end;var
      MainForm: TMainForm;implementation{$R *.dfm}procedure TMainForm.WMSysCommand(var Msg: TWMSysCommand);
    begin
      if Msg.CmdType = SC_MINIMIZE then
        Hide
      else if Msg.CmdType = SC_RESTORE then
        Show;end;end.
      

  2.   

    你的思路有问题啊。
    不能光考虑当前的程序,还应该考虑Windows的处理机制,主要Windows的消息处理机制。
    建议先看看这方面的资料。
      

  3.   

    procedure TForm1.wmSysCommand(var Msg:TWMSysCommand);
    begin
      if msg.CmdType=SC_MINIMIZE then
      ShowWindow(Application.Handle, SW_HIDE);
      DefaultHandler(msg);//重要别忘了加这一句
    end;
    这样子就好了。
      

  4.   

    procedure TForm2.wmSysCommand(var Msg:TWMSysCommand);
    begin
      hide;
    end;