- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 单击最小化按钮隐藏单击托盘显示
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.