InstallMenuCallback

int InstallMenuCallback (int menuBarHandle, int menuOrMenuItemID, MenuCallbackPtr eventFunction, void *callbackData);

Purpose

Installs a menu callback for a specific menu or menu item.

InstallMenuCallback takes a menu bar handle and menu/menu item ID, the name of the event function, type MenuCallbackPtr, that processes commit events for the menu/menu item, and callback data of any type.

After you install the callback, the event function is called whenever the user generates an event on the menu or menu item.

When a commit event is generated by a menu selection, the event function receives the menu bar handle, menu item ID, and panel handle of the menu bar generating the event, and the callback data for processing.

You do not need to call InstallMenuCallback if you already associated a callback function with the menu bar through one of the following mechanisms: the Edit Menu Bar dialog box in the User Interface Editor or the NewMenuItem function.

Callbacks are initiated through RunUserInterface or GetUserEvent.

Note  To uninstall the callback, pass NULL for eventFunction.

Parameters

Input
Name Type Description
menuBarHandle integer Specifier for a particular menu bar that is currently in memory. You obtain this handle from LoadMenuBar or NewMenuBar.

If the menu bar was automatically loaded through LoadPanel, use GetPanelMenuBar to get the menu bar handle.
menuOrMenuItemID integer ID that you assigned to the menu or menu item in the User Interface Editor or that you obtain from NewMenu, NewSubMenu, or NewMenuItem.

If the attribute corresponds to the entire menu bar, pass 0 as this parameter.
eventFunction MenuCallbackPtr Name of the function that processes the menu events.

The event function, type MenuCallbackPtr, takes the following form:

void CVICALLBACK EventFunctionName (int menuBarHandle, int menuItemID, void *callbackPtr, int panelHandle);

When a commit event is generated by a menu selection, the event function receives the menu bar handle, menu item ID, and panel handle of the menu bar generating the event, and the callback data for processing.

The following event is a possible menu event:

Event Event Data
EVENT_COMMIT eventData1 = panel for menu selections
eventData2 = callback data for menuItems (cast to integer)


Note  To uninstall the callback, pass NULL for this parameter.
callbackData void * Points to data that you define. The callback function receives the pointer.

Return Value

Name Type Description
status integer Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Code Error Message String
xx Success