Nuli
Nuli

Reputation: 23

Delphi TTrayIcon BalloonFlags Customize icon

I want to change the icon in the balloon.

TrayIcon1.BalloonFlags := bfWarning;

This type can be selected only four kinds of icons. I would like to put your own icons. Help me..

Upvotes: 2

Views: 386

Answers (1)

David Heffernan
David Heffernan

Reputation: 612954

This control is a wrapper around the Win32 API Shell_NotifyIcon. As such it reflects to you the capabilities offered by the platform, mostly.

The available icons are described in the documentation for the associated struct, NOTIFYICONDATA. The options are:

  • NIIF_NONE: No icon.
  • NIIF_INFO: An information icon.
  • NIIF_WARNING: A warning icon.
  • NIIF_ERROR: An error icon.
  • NIIF_USER: Windows XP SP2 and later. Windows XP: Use the icon identified in hIcon as the notification balloon's title icon. Windows Vista and later: Use the icon identified in hBalloonIcon as the notification balloon's title icon.

This means that the underlying API supports user icons. But the Delphi wrapper does not offer you access to that functionality.

The solution is to call Shell_NotifyIcon directly, specifying NIIF_USER and passing the icon in hBalloonIcon. Or in hIcon if your code is executing on XP.

Upvotes: 1

Related Questions