Admin Production ni-theme
Current Publication

Programming with Panels

LabWindows/CVI

Programming with Panels

Panel Functions

LoadPanel loads into memory a panel created in the User Interface Editor and saved in a .uir file. When using LoadPanel, refer to the panel by the constant name that you assigned to the panel in the User Interface Editor. LoadPanel returns a handle that you use in subsequent User Interface Library functions to refer to the panel. Use the first parameter of LoadPanel to specify whether the panel loads as a top-level window or as a child of another (parent) window. Loading a panel does not automatically display the panel. Use LoadPanelEx, instead of LoadPanel, to load a panel in a DLL if the DLL contains the callback functions for the panel and its controls.

Use the following functions to manipulate panels in a user interface:

NewPanel creates a new panel during program execution. NewPanel returns a handle that you use in subsequent User Interface Library functions to reference the panel. Use the first parameter of NewPanel to specify whether the panel is created as a top-level window or as a child of another (parent) window. You also specify the name, position, and size of the panel through parameters to NewPanel. Creating a new panel using NewPanel does not automatically display the panel.

DuplicatePanel creates a new panel that is a duplicate of a panel loaded by LoadPanel or created by NewPanel. DuplicatePanel returns a handle you use to reference the panel in subsequent operations. Use the first parameter of DuplicatePanel to specify whether the panel is created as a top-level window or as a child of another (parent) window. You also specify the name and position of the panel through parameters to DuplicatePanel. Creating a new panel using DuplicatePanel does not automatically display the panel.

DisplayPanel displays a panel. When a panel is visible and enabled, the user can operate it. Calling DisplayPanel when a panel is already displayed causes the panel to be completely redrawn.

HidePanel hides a panel. When a panel is hidden, it can still be updated. For example, you can add plots to a graph control on a hidden panel. When the panel is redisplayed, it shows the new plots. A hidden panel cannot generate events.

DefaultPanel restores all panel controls to their default values. If the panel is visible, it is updated to reflect the new control values. You assign default values to controls in the User Interface Editor or through SetCtrlAttribute using ATTR_DFLT_VALUE.

GetActivePanel obtains the handle of the currently active panel.

SetActivePanel makes a particular panel active when multiple panels are visible.

GetPanelAttribute obtains a particular attribute of a panel.

SetPanelAttribute sets a particular attribute of a panel.

SetPanelPos changes the position of a panel on the screen. If the panel is visible, it is redrawn in its new position.

SetPanelSize changes the size of a panel. If the panel is visible, it is redrawn with its new size.

SavePanelState saves the state of a panel to a file on disk. SavePanelState saves the value of every control, including the plot data in graphs and strip charts and the current items in list boxes.

RecallPanelState recalls a state file from disk to a panel. Every control on the panel is set to the value stored in the state file. You must recall the state file to the same panel from which it was saved.

DiscardPanel removes a panel from memory. If the panel is visible, it is removed from the screen.

Processing Panel Events

If you want to process events such as mouse clicks, panel moves, or panel sizing, you must assign a callback function to the panel. When an event is generated on the panel, the panel callback function executes.

If you create a panel in the User Interface Editor, you can assign a callback function name to the panel from within the editor. When you load the panel with LoadPanel, LabWindows/CVI automatically installs your callback function and calls it whenever an event is generated on the panel.

If you create a panel programmatically using the NewPanel function, you can install a callback function for the panel using InstallPanelCallback. Your callback function is called whenever an event is generated on the panel. You should use the PanelCallbackPtr typedef from userint.h as a model to declare your panel callback function.

Callbacks must be initiated through a call to RunUserInterface or through a GetUserEvent loop.