单击最小化按钮隐藏单击托盘显示

附件:https://files.cnblogs.com/xe2011/OnMinsize.rar

 

 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    TrayIcon1: TTrayIcon;
    procedure TrayIcon1Click(Sender: TObject);
  private
    procedure OnMinsize(var msg: twmsyscommand);
    message wm_syscommand;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.OnMinsize(var msg: twmsyscommand);
begin
  if msg.CmdType = SC_MINIMIZE then
  begin // 此处添加对最小化事件的处理过程
    Hide();
    msg.CmdType := SC_DEFAULT;
  end;
  inherited;
end;

procedure TForm1.TrayIcon1Click(Sender: TObject);
begin
  Visible := not Visible;
end;

end.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2014-01-05 12:17  XE2011  阅读(214)  评论(0编辑  收藏  举报