Creating a DTC

You can use a variety of development tools to create and test a DTC. This SDK provides generic procedures for using choices as well as specific code samples for Visual Basic and Visual C++. If you are using Visual Basic or Visual C++, you might find the walkthroughs helpful. They describe specific commands and code to create and test a DTC. For testing, these samples assume you are targeting Visual InterDev and its editor as your target environment.

This SDK includes type libraries and documentation you need to write your own design-time controls. As for development tools, you can use any tool that can create ActiveX controls, including:

Creating a DTC includes the following general steps, including those for publishing and subscribing to choices. The code A Choices Walkthrough in Visual Basic and Visual C++ have samples for completing each of these steps.

To create a DTC that uses choices

  1. Create an ActiveX control and the user interface.

    Note   When creating a DTC, use property pages instead of inline user interface for setting a DTC's properties. An inline user interface is the graphical representation of the DTC within the hosting document such as a form or other object with controls that accept user input. Although Visual InterDev 6.0 supports inline user interface, this is not a guarantee that all DTC hosts are required to support it now or in the future.

  2. Add design-time control support to the ActiveX control by implementing the DTC interfaces.
    Filename Reference Display name Object Browser name
    dtc60.tlb Microsoft DTC 60 Type Library DTC60
    webdc.tlb Microsoft Web Design-time Control Type Library MSWDCTL
    *dbsrvice.tlb VID 6.0 Data Services Support Type Library 1.0 DBServiceLib

    * Add a reference to this library if your DTC requires the Query Builder, URL picker, or Color picker.

  3. Implement a DTC Control site to establish communications with the Choices Engine.

  4. For publishing choices, create one or more Choice objects and specify their Types.

    Note   When defining a new Choice type, be sure to specify each of the Choice object's properties. If you want to provide additional information about the choice, include Tags as well.

    Tip   Prefixing the type with the ProgID of the publishing DTC can help you prevent unwanted interaction with choices from other DTCs. This convention is especially helpful if you are working with multiple DTC developers.

  5. For subscribing to choices, create a ChoiceSink and ChoiceFilter to specify the type of Choices the DTC can use.

    Note   Use the conversion rules as appropriate when comparing the type of a Choice object to a ChoiceFilter object.

  6. Use the choice. If the DTC subscribes to static choices, get the choice value by evaluating the ChoiceSink's BoundChoice property. For dynamic choices, use the OnRebind method.

  7. Persist the published and selected choice values so that they can be restored when the document that uses the DTC is reopened.

  8. Specify the run-time text to be put in the document.

    Note   The method you implement to do this depends on the language you are using. For Visual Basic projects, use the GetRunTimeText method of the IProvideRuntimeText interface. For Visual C++ and other types of projects, use the SaveRuntimeState method of the IActiveDesigner interface.

    The output is handled differently in Visual Basic because it doesn't process text streams the same way as other languages.

After creating your DTC, you can build, register, and test it. The way you build and register depends on the language you are using. See Testing a DTC's Output.