Admin Production ni-theme
Current Publication

NewCtrlMenuItem

LabWindows/CVI

NewCtrlMenuItem

int NewCtrlMenuItem (int panelHandle, int controlID, char itemLabel[], int beforeMenuItemID, CtrlMenuCallbackPtr eventFunction, void *eventCallbackData);

Purpose

Adds a new menu item to the menu owned by the specified control and returns the new menu item ID that you can use in subsequent calls to specify the menu item.

Supported Controls

You can use NewCtrlMenuItem with the following controls:

Parameters

Input
Name Type Description
panelHandle int Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel.
controlID int The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl.
itemLabel char [] The name of the new menu item.

To add an underline accelerator to an item name, precede the letter to be underlined with two underscores; for example __Open.
beforeMenuItemID int The menu item ID above which to insert the new menu item.

Use a menuItemID you obtained from NewCtrlMenuItem or NewCtrlMenuSeparator, or use a constant that identifies one of the built-in control menu items. The following lists the built-in menu item constants:

Constant Name Constant Value Control Type
VAL_GOTO –2 Table
VAL_FIND –3 Table, tree
VAL_SORT –4 Table, tree
VAL_EXPAND_SUBTREE –5 Tree
VAL_COLLAPSE_SUBTREE –6 Tree
VAL_EXPAND_ALL –7 Tree
VAL_COLLAPSE_ALL –8 Tree
VAL_PLOT_COLOR –9 Graph, strip chart
VAL_PLOT_STYLE –10 Graph, strip chart
VAL_PLOT_POINT_STYLE –11 Graph, strip chart
VAL_PLOT_LINE_STYLE –12 Graph, strip chart
VAL_PLOT_BGCOLOR –13 Graph
VAL_PLOT_ORIGIN –14 Graph
VAL_PLOT_FONT –15 Graph
VAL_PLOT_FILL_COLOR –16 Graph
VAL_PLOT_VISIBLE –17 Graph, strip chart
VAL_PLOT_RENAME –18 Graph, strip chart
VAL_PLOT_LINE_THICKNESS –19 Graph, strip chart
VAL_FIND_NEXT –20 Table, tree
VAL_FIND_PREV –21 Table, tree


To place the new menu item at the bottom of the menu item list, pass –1.
eventFunction CtrlMenuCallbackPtr The name of the function that processes the menu callback. This event function, type CtrlMenuCallbackPtr, takes the following form:

void CVICALLBACK FunctionName (int panelHandle, int controlID, int MenuItemID, void *callbackData);

When a menu selection generates a commit event, this function receives the panelHandle and controlID of the control that owns the menu generating the event and the Menu Item ID corresponding to the menu item selected. This function also receives the value you pass to eventCallbackData.
eventCallbackData void * Points to data that you define. The callback function receives the pointer.

If you do not need to pass user-defined data to the callback function, or if you are not using a callback function to process the menu item event, you can use a value of zero.

Return Value

Name Type Description
menuItemID int Returns the ID that you use to specify this menu item in subsequent function calls. Negative values indicate that an error occurred. Zero is not a valid ID.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Examples

Refer to the following examples that use the NewCtrlMenuItem function:

  • userint\databinding.cws

    Open example
  • userint\events.cws

    Open example
  • userint\TreeBusDigitalGraph.cws

    Open example
  • userint\treeList.cws

    Open example
  • userint\treemenu.cws

    Open example