TrayIcon1.Visible
一定要设为True
01]绑定右键菜单02]汽泡显示信息
03]托盘闪烁
04]更改ico图标
01]绑定右键菜单
拖一个PopupMenu1,设置好菜单,绑定即可显示
02]汽泡显示信息
procedure TForm1.Button1Click(Sender: TObject);
begin
TrayIcon1.BalloonFlags:=bfWarning; //bfNone, bfInfo, bfWarning, bfError
TrayIcon1.BalloonHint:='TrayIcon1汽泡显示';
TrayIcon1.BalloonTitle:='警告:';
TrayIcon1.BalloonTimeout:=2000; // 持续时间
TrayIcon1.ShowBalloonHint;
end;
03]托盘闪烁
添加一个ImageList1,添加好图标后
procedure TForm1.FormCreate(Sender: TObject);
begin
TrayIcon1.Icons := ImageList1;
TrayIcon1.AnimateInterval := 100; //闪烁间隔时间 毫秒
end;
procedure TForm1.Button2Click(Sender: TObject);//开始托盘闪烁
begin
TrayIcon1.Animate := True;
end;
procedure TForm1.Button3Click(Sender: TObject);//停止闪烁
begin
TrayIcon1.Animate := False;
end;
04]更改ico图标 (06)将资源装进Res,就不用引用磁盘文件
procedure TForm1.Button5Click(Sender: TObject);
begin
//TrayIcon1.Icon.LoadFromFile('33.ico');
TrayIcon1.Icon.LoadFromResourceName(Hinstance,'33');
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
//TrayIcon1.Icon.LoadFromFile('13.ico');
TrayIcon1.Icon.LoadFromResourceName(Hinstance,'13');
end;
标签:begin,end,Sender,05,系统托盘,TForm1,TObject,TrayIcon1
From: https://blog.51cto.com/u_15216366/9064778