# NewMenuItem

int NewMenuItem (int menuBarHandle, int menuID, char itemName[], int beforeMenuItemID, int shortCutKey, MenuCallbackPtr eventFunction, void *callbackData);

## Purpose

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

## 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.
menuID | integer | ID for a particular menu within a menu bar. The ID must be a constant name, located in the .uir header file, that you assign in the User Interface Editor or a value that you obtain from NewMenu.
itemName | string | 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 | integer | Menu item ID above which to insert the new item. To place the new menu item at the bottom of the menu item list, pass –1.
shortCutKey | integer | The key or key combination the user can press to automatically select the menu item. Shortcut keys are 4-byte integers consisting of three bit-fields, 0x00MMVVAA, where: MM = the modifier key VV = the virtual key AA = the ASCII key You cannot use a dual-byte character as a shortcut key. When you construct a shortcut key, you can bitwise OR modifier keys with a virtual key or with an ASCII key. Either the ASCII field or the virtual key field must be all zeros. For example, the following construct produces a shortcut key of <Shift-F1>: VAL_SHIFT_MODIFIER | VAL_F1_VKEY Similarly, the following construct produces a shortcut key of <Ctrl-D>: VAL_MENUKEY_MODIFIER | 'D' Virtual keys do not require modifiers, but ASCII keys require at least one modifier. The following modifier keys are available: VAL_SHIFT_MODIFIER VAL_UNDERLINE_MODIFIER (the <Alt> key) VAL_MENUKEY_MODIFIER (the <Ctrl> key) VAL_SHIFT_AND_MENUKEY The following virtual keys are available: VAL_FWD_DELETE_VKEY VAL_BACKSPACE_VKEY VAL_ESC_VKEY VAL_TAB_VKEY VAL_ENTER_VKEY VAL_UP_ARROW_VKEY VAL_DOWN_ARROW_VKEY VAL_LEFT_ARROW_VKEY VAL_RIGHT_ARROW_VKEY VAL_INSERT_VKEY VAL_HOME_VKEY VAL_END_VKEY VAL_PAGE_UP_VKEY VAL_PAGE_DOWN_VKEY VAL_F1_VKEY VAL_F2_VKEY VAL_F3_VKEY VAL_F4_VKEY VAL_F5_VKEY VAL_F6_VKEY VAL_F7_VKEY VAL_F8_VKEY VAL_F9_VKEY VAL_F10_VKEY VAL_F11_VKEY VAL_F12_VKEY The following lists the possible ASCII keys: 'A' or 'a' 'B' or 'b' 'C' or 'c' . . . 'Z' or 'z'
| Note There is no distinction between upper and lower case ASCII keys.
eventFunction | MenuCallbackPtr | Name of the user function that processes the menu item callback. If you want to process the menu item event through a callback function, supply the name of that function as the eventFunction parameter. The event function, type MenuCallbackPtr, is prototyped as follows: void CVICALLBACK EventFunctionName (int menuBarHandle, int menuItemID, void *callbackData, int panelHandle); The event function receives the menu bar handle, itemID, and panel handle of the menu item that generates the callback. It also receives a pointer to callback data that you define. If you do not want to process the menu item event through a callback function, supply a value of zero for the eventFunction parameter.
callbackData | 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 | integer | 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.
Code | Error Message String
xx | (Menu item ID) Success