Using TestStand UI Controls in LabWindows/CVI
- Updated2025-07-23
- 3 minute(s) read
You can create custom user interfaces and create user interfaces for other components, such as custom step types. Use the TestStand User Interface (UI) Controls in the LabWindows/CVI development environment to develop a custom user interface application, including custom sequence editors.
Creating and Configuring ActiveX Controls
In the LabWindows/CVI User Interface Editor, select Create»ActiveX and select a user interface control beginning with TestStand UI to add a TestStand UI Control to a panel. Double-click the control to launch the standard LabWindows/CVI Edit Control dialog box, in which you can configure the control. Right-click the control and select Properties from the context menu to open the property pages the UI control supports.
Programming with ActiveX Controls
To access the methods, properties, and events specific to an ActiveX control, you must use the ActiveX driver for the control. The TestStand UI Controls driver and additional support instrument drivers are located in the <TestStand>\API\CVI directory. TestStand copies these instrument driver files (.h, .c, .fp, and .obj) to the <National Instruments>\Shared\CVI\instr\TestStand\API directory. The TestStand Version Selector copies API files for earlier versions of LabWindows/CVI to the appropriate locations.
Add the following function panel files to the LabWindows/CVI project for a TestStand application and add the corresponding header files in the source code files that use the API:
- TestStand UI Controls (tsui.fp)—Functions for dynamically creating controls, calling methods and accessing properties on controls, and handling events from the controls.
- TestStand UI Support Library (tsuisupp.fp)—Functions for various collections the TestStand UI Controls driver uses.
- TestStand Utility Functions (tsutil.fp)—Utility functions for managing menu items that correspond to TestStand commands, localizing strings in user interfaces, making dialog boxes associated with LabWindows/CVI code modules modal to TestStand applications, and checking if an execution that calls a code module has stopped.
- TestStand API (tsapicvi.fp)—Provides low-level access to TestStand objects.
For each interface the ActiveX control supports, the driver contains a function you can use to programmatically create an instance of the ActiveX control. The ActiveX driver also includes functions you can use to register callback functions for receiving events the control defines.
When you store ActiveX controls in .uir files, you do not need to use the creation functions the driver includes because the control is created when you load the panel from the file using the LoadPanel function. You identify the control in subsequent calls to User Interface Library functions with the constant name you assigned to the control in the User Interface Editor.
When you use other functions in the driver, you must identify the control with a unique object handle that LabWindows/CVI then associates with the control. You obtain this handle when you call the GetObjHandleFromActiveXCtrl function using the constant name for the control. This handle is cached in the control, and you do not need to discard the handle explicitly.
LabWindows/CVI requires you to initialize a thread as apartment-threaded before you can use ActiveX controls in a program. When you do not initialize the thread before creating an ActiveX control or before loading a panel containing an ActiveX control from a .uir file, LabWindows/CVI automatically initializes the thread to apartment-threaded. When you use the CA_InitActiveXThreadStyleForCurrentThread function to initialize the thread yourself, you must use COINIT_APARTMENTTHREADED as the threading model.
Include Files and Instrument Search Directories
The TestStand Version Selector automatically adds the additional required API files to shared directories for the installed versions of LabWindows/CVI. If you have just installed a new version of LabWindows/CVI, the API files are not available until after you launch the TestStand Engine, at which point the TestStand Version Selector detects the new version of LabWindows/CVI and copies the required API files. You can also launch the TestStand Version Selector, select the current version of TestStand, and click the Make Active button to re-activate the current version of TestStand and to re-copy the API files.