Tray Icon Properties

Instead of having a button in the taskbar, you may prefer your application to show a small tray icon:

Tray Icon

If so, turn on "Enable Tray Icon". The small icon displayed is the one of the application EXE file.

The tray icon optionally displays a popup menu when end users right-click the tray icon.


In Windows 7 and later, all tray icons may not always be visible by default. This is a normal behavior and end users can adjust tray icon bar settings to modify it.


When you select the "Tray Icon" component in the "Components Used" list, the following properties are available.

Default Hint Text

This is the text displayed in the hint when hovering over the tray icon.

Show Minimized on Start

When this option is enabled, the application starts minimized: the main window is not displayed, only its tray icon is visible.

The Close button Minimizes the Main Window

By default, when you hit the Close system button, the application exits. If you want to avoid your application from exiting, use this option. It will force the main window to minimize to the tray when the close button is hit.

In that case, ensure to give end users an option to exit your application (like a menu command in the tray's popup menu). Otherwise, they will need to end the application manually with the task manager.

Always minimize to tray

If you enable this option, the main window is always minimized to the tray, not in the taskbar. Otherwise, a taskbar button will appear when the main window is minimized.

Edit Popup Menu

Lets you manage the entries for the tray menu thanks to the UI editor. This menu appears when end users right-click the tray icon. It should at least contain two commands: Restore and Exit. These commands are automatically created by ExeOutput for PHP for each new project and it is recommended that you leave them.

Edit Popup Menu

Click Edit Popup Menu and the UI editor is shown.

  • Select the TPopupMenu control

Select the TPopupMenu control

  • Double-click on (Menu) in Properties Editor

Double-click on (Menu) in Properties Editor

  • Click "New Item" to add a new item or "New Subitem" to create a child item

Click "New Item" to add a new item or "New Subitem" to create a child item

For the Caption property, you can use Resource Strings for easier localization. To insert a resource string, use %RESID% and replace RESID with the name of the resource string.

Change Icon Programmatically

Thanks to the HEScript built-in call named TrayChangeIcon, you can change the icon displayed in the tray at runtime. By default, the application's icon is used.

procedure TrayChangeIcon(const IconFile: String);

IconFile must point to the full path to an external icon file or the virtual path to an icon file compiled inside the application.


The file must be a true icon file (.ICO extension). To create icon files in ICO format easily, GConvert is a solution.

Code Example: modify tray icon at startup

Place the sample1.ico in your application's Source Folder so that it is in the root. Then, edit the UserMain script and locate the OnStartMainWindow event. Replace it by:

procedure OnStartMainWindow; begin TrayChangeIcon("sample1.ico"); end;

Thus, when the application starts, the custom icon sample1.ico will be used as tray icon.