# InsertTrayIconMenuItem

int InsertTrayIconMenuItem (int iconHandle, const char itemName[], int *itemIndex);

## Purpose

This function adds an item to the specified icon's right–click popup menu. Items are added in order, with the first item being item 1, and grow vertically on the popup menu.

The Callback Function specified in InstallSysTrayIcon will receive EVENT_MENU_ITEM events when the user selects a menu item. eventData will contain the 1–based index of the selected item. The callback function will receive EVENT_RIGHT_CLICK events before any associated popups are diplayed. If you return non–zero from the callback function upon receiving these events, the popup menu will not be displayed.

See the Class Help for more information on the recommended usage of System Tray icons and their popup menus.

## Parameters

Input
Name | Type | Description
iconHandle | integer | The handle of the System Tray icon for which you wish to add a a popup menu item. This handle will have been returned from InstallSysTrayIcon.
itemName | const char [] | A NULL–terminated string indicating the name of the popup menu item. This is the name which will appear on the popup menu. If you pass NULL, then the created item will be a separator, for which you will not receive events.
Output
Name | Type | Description
itemIndex | integer * | The 1–based index of the newly inserted item.

## Return Value

Name | Type | Description
status | integer | 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.