VCL.TrayIcon Sample

From RAD Studio XE2 Code Examples
Jump to: navigation, search

Language:

This sample demonstrates how to add a tray icon in the Explorer tray bar.

Contents

Location

You can find the trayicon sample project at:

Description

The application creates a form that allows the user to choose an icon and place it in the tray bar. The form contains two radio buttons to indicate the state in which the icon should be: on or off. To add the selected icon on the tray, select Place on tray. Click Hide to hide the main form, but keep the icon on the tray. The icon has attached a pop-up menu to allow the user to change the state, see the main form even if it was hidden, or exit the application.

How to Use the Sample

  1. Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open trayicon.cbproj.
  2. Press F9 or choose Run > Run.

Files

The project contains one source file, traymain.pas, which contains the main form class.

Classes

TFormMain, the class corresponding to the main form, handles the system calls to add and modify the icon on the tray bar.

Implementation

  • The TrayMessage method constructs the data structures necessary to call Shell_NotifyIcon, which sends a message to the system tray bar.
  • Show and Hide set the visibility of the form to True and False, respectively.

Uses

See Also

Personal tools
Previous Versions