Admin Production ni-theme
Current Publication

LoadPanel

LabWindows/CVI

LoadPanel

int LoadPanel (int parentPanelHandle, char filename[], int panelResourceID);

Purpose

Loads a panel into memory from a user interface resource (.uir) file or text user interface (.tui) file you created in the User Interface Editor.

The panel becomes a child panel of the parent panel you specify by parentPanelHandle. To make the panel a top-level panel, pass 0 for the parentPanelHandle.

The function returns a panel handle that you use in subsequent function calls to specify the panel. You must call DisplayPanel to make the panel visible.

If you call this function to load a panel as a child panel, you must do so in the same thread in which you create the parent panel.

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 Run»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, LoadPanel returns an error if LabWindows/CVI cannot find in the project any of the callback functions referenced in the .uir for the panel. If you want to allow a panel 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 LoadPanel, each panel and control 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. If a DLL is linked into your project or dynamically loaded, LabWindows/CVI searches only the symbols exported through the import library.

If you defined callback functions in a DLL but did not export them, LoadPanel cannot find the callback functions. Instead, you must call LoadPanelEx from the DLL.

Example Code

The following example code demonstrates how to load, display, and then discard a user interface panel. TESTPANEL is the constant name assigned to the panel in the Edit Panel dialog box in the User Interface Editor. panelHandle is the specifier that you use to identify the panel in subsequent User Interface Library function calls.

int main (int argc, char *argv[])

{

int panelHandle;

/* initialize the LabWindows/CVI Run-Time Engine and load the user interface panel into memory */

if (InitCVIRTE (0, argv, 0) == 0)

return -1;

if ((panelHandle = LoadPanel (0, "test.uir", TESTPANEL)) <= 0)

return -1;

/* display the panel and run the UI */

DisplayPanel (panelHandle);

RunUserInterface ();

/* free resources and return */

DiscardPanel (panelHandle);

CloseCVIRTE ();

return 0;

}

Parameters

Input
Name Type Description
parentPanelHandle int Handle of the panel into which to load the panel as a child panel. Pass 0 to load the panel as a top-level window.

You can obtain this handle from functions such as LoadPanel and NewPanel.
filename char [] Name of the .uir or .tui that contains the panel.

You can use a complete pathname or a simple filename for filename. If the name is a simple filename that contains no directory path, the file is loaded from the directory that contains the executable.

You must call LoadPanelEx with a valid calling module handle to load an embedded .uir file from a DLL if you enable the Embed project .UIRs option in the Target SettingsTarget Settings dialog box.
panelResourceID int Defined constant that you assigned to the panel in the User Interface Editor.

The panelResourceID is found in the .uir header file and you use it only to load the panel into memory. You use the panel handle this function returns to refer to the panel in subsequent function calls.

When you load a panel from a text user interface (.tui) file, the panelResourceID parameter must be the header number of the .tui file section that defines the panel. For example, if the section header for the panel is [Panel003], pass 3 as the panelResourceID.

This function loads all of the controls in the .tui file whose section headers take the form [PanelNNN_ControlYYY], where NNN is the panelResourceID and YYY is 001 or greater. The control numbers must be consecutive and start at 001. To specify the control in calls to other User Interface Library functions, pass YYY + 1 as the controlID. For example, if the section header for the control is [Panel003_Control001], pass 2 as the controlID parameter.

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 panel and control constants in the include file as parameters to User Interface Library functions.

Return Value

Name Type Description
panelHandle int Value you can use in subsequent function calls to specify this panel. Negative values indicate that an error occurred. Zero is not a valid panel handle.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the LoadPanel function:

  • apps\uirview\uirview.cws

    Open example
  • userint\panels.cws

    Open example