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,就不用引用磁盘文件

begin
  TrayIcon1.IconIndex:=1;                  //调用ImageList1里的图标
  TrayIcon1.Icon.LoadFromFile('33.ico');   //从硬盘文件导入
  TrayIcon1.Icon.LoadFromResourceName(Hinstance,'33');    //从资源文件里导入
end;

 直接设置其Icon属性

 使用当前程序图标: TrayIcon1.Icon := Application.Icon;