LabWindows/CVI

Content Type
Programming Language
Current manual

InstallMenuCallback

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 int Specifier for a particular menu bar that is currently in memory. You can obtain this handle from functions such as LoadMenuBar and NewMenuBar.

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

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 int Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?

Help us improve your future ni.com experience.

Did you find the documentation you were looking for?

Submit