Share via


TSTCON Sample: ActiveX Control Test Container

The TSTCON sample implements an ActiveX control container using MFC support for OLE embedding. You can use TSTCON to test ActiveX controls, change their properties, and invoke their methods. You can write scripts using the VBScript language to automate the testing of the controls. TSTCON can keep a log of the events and property change notifications fired by a control.

Note

This sample requires the Microsoft Calendar Control, which is installed with Microsoft Access.

TSTCON also demonstrates several MFC programming topics, including the following topics:

  • CCheckListBox: A list box with a check box next for each item.

  • CDragListBox: A list box in which you can drag the items to rearrange their order.

  • Implementing an Active Scripting Engine host (VBScript).

  • Implementing context-sensitive help for dialog boxes.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

Building and Running the Sample

To build and run the TSTCON sample

  1. Open the solution tstcon.sln.

  2. On the Build menu, click Build Solution.

  3. Run the test container application as a stand-alone application so it can register itself with the system.

To launch a control in the container

  1. In ActiveX Control Test Container, from the Edit menu, click Insert New Control.

  2. In the Insert New Control dialog box, from the list box, select Calendar Control, and click OK.

    The Microsoft Calendar Control appears in the upper half of the splitter window. Note that this control is installed with Microsoft Access.

  3. Manipulate the calendar by changing month, year, and date. In the lower pane, observe how the logs, events, and property change notifications are fired by the control as you manipulate it.

To change the control's properties

  1. Select the calendar control by clicking the calendar's border.

  2. From the Edit menu, click Properties. Test Container displays the Properties dialog box for the control.

  3. Using this dialog box, you can edit the properties of the control. Change the control's properties and observe the changes.

  4. Close the Properties dialog box.

To invoke methods on the control

  1. From the Control menu, click Invoke Methods. The Invoke Method dialog box appears.

  2. In the Method Name combo box, select BackColor (PropPut).

  3. From theParameter Type combo box, select VT_COLOR.

  4. Click Choose Color, choose a color from the color palette, and click OK.

  5. In the Invoke Methoddialog box, click Invoke. The background color of the calendar control changes to the color you selected in the color palette.

For more information on how to use the Test Container, from the Help menu, click Help Topics.

Note

Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

See Also

Other Resources

MFC Samples