TSTCON Sample: ActiveX Control Test Container

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.

NoteNote:

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 provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from theVisual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

To build and run the TSTCON sample

  1. Open the solution tstcon.sln.

  2. In the Property Pages for the TCProps project, expand theConfiguration Properties node; then expand the Linker node. Under Manifest File, change the Enable User Account Control (UAC) option to No.

  3. On the Build menu, click Build Solution.

  4. 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 NewControl.

  2. In the Insert New Control dialog box, from the list box, selectCalendarControl, 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 theProperties 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. TheInvoke 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 clickOK.

  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.

NoteNote:

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.

Other Resources
        Did you find this helpful?           
(2000 characters remaining)
Community Content Add
Annotations FAQ
ocscpy deprecated
            The compler complains that ocscpy is unsafe.
edit TCDoc.Cpp, line 484 (or there abouts), to replace ocscpy with:

size_t len = wcslen( pszFaceName )+1;
ocscpy_s( m_descFont.lpstrName, len, pszFaceName );

The instructions were incorrect for my computer: Visual Studio 2008, Windows 7, 64 bit.
Opening TstCon.sln did not work.
Open TstConLKG8.sln

Warning D9035: option Wp64 has been deprecated.  I found the command line options and changed that from Yes to No.  The warning returned.  I don't know where to look to make a permanent change.

Comments and elaborations from someone more knowledgable will be appreciated.


  •               7/16/2011             
  • JAG77
Build Error for Win32 Vista Ultimate
            To build on on Vista 32 bit bit platform do the following

1. Add bellow line to stdafx.h in the beginning
#define WINVER 0x500
2. Change the project setting with a right click on the project - choose properties Repeat this for both projects TCProps and TSTCon
2a. Select Configuration properties Change default platform located at the top to 'Active(Win32)' and Click on Configuration manager and Change Active Solution platform to be 'Win32', close it
2b. Change Configurations Properties\Linker\Manifest File\Enable User Access Control (UAC) to 'No'

Fix also works on Windows 7 / 64 bit       
vs2010 中添加 ActiveX Control Test Container工具(转载) vs2010中的TSTCON( ActiveX Control Test Container )工具非自动安装,而是作为一个例程提供。所以应找到该例程,并编译: 如vs2010安装在默认路径则 1, 进入:C:\Program Files\Microsoft Visual Studio 10.0\Samples\1033,可找到VC2010Samples.zip文件, 2, 将其解决到同一个文件夹,解压后将出现一个C++子文件夹。 3, TstCon例程在:C:\Program Files\Microsoft Visual Studio 10.0\Samples\1033\C++\MFC\ole\TstCon,双击其中的.sln文件启动工程,直接编译, 4, 编译后在Debug子文件夹中将出现一个TstCon.exe文件,将其复制到:C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools文件夹。 5, 在vs2010中的Tools菜单点击“External Tools...”,出现如下对话框,点击“Add”添加一项工具。 6, 新工具项的"Title"为:ActiveX Control Test Container,"Command"为:C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\TstCon.exe。 7, 确认退出对话框,Tools菜单将出现“ActiveX Control Test Container”菜单项。完毕! 同理在2015安装目录下找到并编译: 但是编译的时候需要区分win32和x64的不同平台生成的工具 分别添加 ActiveX Control Test Container 32和 ActiveX Control Test Container 64的工具,因为不同工具显示的是不同平台注册的com组件,比如你注册一个32位的com组件,此时只能用ActiveX Control Test Container 32测试,而在ActiveX Control Test Container 64中是找不到这个com组件的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值