To use the TestStand User Interface (UI) Controls in Microsoft Visual C++, add the TestStand Utility (TSUtil) Functions Library to the project. The TSUtilCPP.cpp and TSUtilCPP.h files automatically import the type libraries for the TestStand API and the TestStand User Interface (UI) Controls.

You can view the header files the #import directive generates for the TestStand API type libraries by opening the tsui.tlh, tsuisupp.tlh, and tsapi.tlh files Visual C++ creates in the Debug or Release directory. The header files the #import directive generates define a C++ class for each object class in the TestStand API. The I prefix in class names denotes ActiveX controls and objects you can create without calling another class. The header files use macros to define a corresponding smart pointer class for each object class. Each smart pointer class uses the name of the corresponding class and adds a Ptr suffix. Typically, you use only smart pointer classes in an application because the smart pointer releases the reference to the object when the pointer is destroyed. For example, instead of using the SequenceFile class, use the SequenceFilePtr class.

Note NI recommends, in accordance with Microsoft guidelines, using the classes the #import directive generates to call the TestStand ActiveX API instead of using the Class Wizard tool to generate Microsoft Foundation Class (MFC) wrapper class files.

Select Insert ActiveX Control from the dialog box context menu and select a control that begins with TestStand UI to add a TestStand UI Control to a dialog box as a resource.

When you programmatically create a TestStand UI Control in an MFC container, you must remove the WS_CLIPSIBLINGS style from the control window for the TestStand UI Control to remain visible inside an MFC Group Box control. If you do not remove the WS_CLIPSIBLINGS style, a native MFC control always obscures the TestStand UI Control, even when the MFC control comes after the TestStand UI Control in the tab order.

Obtaining an Interface Pointer and CWnd for an ActiveX Control

Complete the following steps to obtain an interface pointer to an ActiveX control, such as a TestStand User Interface (UI) control, that you insert into an Microsoft Foundation Class (MFC) dialog resource.

  1. Add a CWnd member to the dialog class for the control as follows:CWnd mExprEditCWnd;
  2. Insert the following code into the OnInitDialog method of the dialog class:mExprEditCWnd.Attach(GetDlgItem (IDC_MYEXPRESSIONEDIT)->m_hWnd);
  3. Obtain the interface pointer from the CWnd member as follows:TSUI::IExpressionEditPtr myExprEdit = mExprEditCWnd.GetControlUnknown();
Note NI does not recommend using DoDataExchange to obtain an interface pointer and CWnd for a TestStand ActiveX User Interface Control because the pointer can be invalid in some instances. Use DoDataExchange only when controls are windowless or do not recreate internal windows.