# LoadMenuBar

int LoadMenuBar (int destinationPanelHandle, char filename[], int menuBarResourceID);

## Purpose

Loads a menu bar into memory from a user interface resource (.uir) file or text user interface (.tui) file you created in the User Interface Editor. The menu bar resides on the panel you specify by the destination panel handle.

The function returns a menu bar handle that you use in subsequent function calls to specify the menu bar.

The ATTR_REPORT_LOAD_FAILURE and ATTR_ALLOW_MISSING_CALLBACKS system attributes affect how this function behaves when it encounters an error. When you run a program in LabWindows/CVI and you enable debugging and the Break on Library Errors option, a message appears when a LabWindows/CVI function returns an error. In general, this feature is not available when debugging is disabled. However, there is a special system attribute to enable error messages for LoadPanel, LoadPanelEx, LoadMenuBar, and LoadMenuBarEx. By default, the attribute is enabled.

By default, LoadMenuBar returns an error if any of the callback functions referenced in the .uir for the menu bar cannot be found in the project. If you want to allow a menu bar to be loaded in this case, enable the ATTR_ALLOW_MISSING_CALLBACKS attribute using the SetSystemAttribute function.

Refer to the list of system attributes for more information.

| Note When you call LoadMenuBar, each menu or menu item callback name you specified in your .uir file is automatically linked to the function of the same name. To find callback functions, LabWindows/CVI searches all of the modules linked in your project and any modules dynamically loaded using LoadExternalModule. If a DLL is linked into your project or dynamically loaded, LabWindows/CVI searches only the symbols exported through the import library. If you have defined callback functions in a DLL but not exported them, LoadMenuBar cannot find them. Instead, you must call LoadMenuBarEx from the DLL.

## Parameters

Input
Name | Type | Description
destinationPanelHandle | integer | Handle of the panel on which to place the menu bar. You obtain destinationPanelHandle from LoadPanel, NewPanel, or DuplicatePanel. If the destination panel is not currently in memory, or if the menu bar is used only as a popup menu, pass a zero as the destination panel handle. You can later assign the menu bar to a panel using SetPanelMenuBar.
filename | string | Name of the .uir or .tui that contains the menu bar. You can use a complete pathname or a simple filename. If the name is a simple filename that contains no directory path, the file is loaded from the directory that contains the executable. If you enable the Embed project .UIRs option in the Target Settings Target Settings dialog box, you must use a simple pathname. If you use a complete pathname, the project will always look for the .uir file on disk, even if the file is embedded in the project. You must call LoadMenuBarEx with a valid calling module handle to load an embedded .uir file from a DLL.
menuBarResourceID | integer | Defined constant that you assigned to the menu bar in the User Interface Editor. The menuBarResourceID is in the .uir header file, and you use it only to load the menu bar into memory. You use the menu bar handle that this function returns to refer to the menu bar in subsequent function calls. When you load a menu bar from a .tui, the menuBarResourceID parameter must be the header number of the .tui file section that defines the panel. For example, if the section header for the menu bar you want is [MenuBar003], pass 3 as the Menu Bar Resource ID. This function loads all of the menus and menu items in the .tui file whose section headers take the form [MenuBarNNN_...], where NNN is the menuBarIDResourceID. The menu ID or menu item ID that you pass to User Interface Library functions is based on a depth-first traversal of all of the items in the menu tree, starting at 2. For submenu items, the submenu has an ID that is one greater than the item ID of the submenu entry in the parent menu. If you save a .tui file in the User Interface Editor in LabWindows/CVI 5.0 or later, and you have an up-to-date include file (.h) that the User Interface Editor generated, you can use the menu bar, menu, submenu, and menu item constants in the include file as parameters to User Interface Library functions.

## Return Value

Name | Type | Description
menuBarHandle | integer | The handle you can use in subsequent function calls to specify this menu bar. Negative values indicate that an error occurred. Zero is not a valid handle.
Code | Error Message String
xx | Success