Admin Production ni-theme
Current Publication

InstallSysTrayIcon

LabWindows/CVI

InstallSysTrayIcon

int InstallSysTrayIcon (const char iconImageFile[], const char toolTipText[], TrayIconCallback callbackFunction, int *iconHandle);

Purpose

This function installs a user–defined icon in the Status area of the Windows Desktop Taskbar (the System Tray). The function specified in the callbackFunction parameter will receive mouse events from the icon.

Use AttachTrayIconMenu to attach popup menus to your System Tray icon.

Use AttachTrayIconBalloonNotification to attach a popup balloon notification to your System Tray icon.

(Linux) This function is not supported.

Parameters

Input
Name Type Description
iconImageFile const char[] A NULL–terminated string indicating the *.ico file to be displayed in the System Tray.
toolTipText const char[] A NULL–terminated string containing the text to be displayed when a user moves the mouse over the System Tray icon. The popup message (a ToolTip) will be displayed in the default system colors. The system will honor a maximum of 64 characters for this string.
callbackFunction TrayIconCallback The callback function to receive events from the System Tray icon. The function should be of the following form:

int CVICALLBACK Func (int iconHandle, int event, int eventData);


When an event occurs on the icon, CVI will call this function. The iconHandle parameter will contain a handle to the icon which generated the event. This handle will have been returned from InstallSysTrayIcon. The event parameter will be one of the following values:

EVENT_LEFT_CLICK
EVENT_LEFT_MOUSE_UP
EVENT_RIGHT_CLICK
EVENT_RIGHT_MOUSE_UP
EVENT_LEFT_DOUBLE_CLICK
EVENT_RIGHT_DOUBLE_CLICK
EVENT_MENU_ITEM

The eventData parameter will be 0 for all events other than EVENT_MENU_ITEM. You will only receive EVENT_MENU_ITEM events if you install a popup menu for this icon. In the case of this event, eventData will contain the ID of the menu item selected.

The callback function should return 0 unless you want to prevent an installed popup menu from appearing (return non–zero in this case).
Output
Name Type Description
iconHandle int Returns a handle to the System tray icon.

Return Value

Name Type Description
status int The status code that the function returns.

0 indicates success.

A negative value indicates an error.

This function may return a Programmer's Toolbox or UI Library error code. Call GetGeneralErrorString to obtain a text description of the error.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Example

Refer to toolbox\trayicon.cws for an example of using the InstallSysTrayIcon function.