Here are some tips and tricks for developing your DTC. They are organized into the following sections:
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.
For examples of DTC's that only use property pages, see the PageTransitions or the Form Manager DTCs that come with Visual InterDev. For more information about creating property pages, see the online documentation for your development tool.
Be sure that your DTC has an About property. Typically, the About property supplies the following information about the DTC.
This minimal documentation becomes especially useful to your users later when they want to get updates or get more information about a specific control.
Be sure that your DTC writes enough information into its persistent state so that when reloaded it can publish the same choices and set the same properties on the filters in its ChoiceSink. You can do this by using a property bag. Both the Visual Basic sample and the Visual C++ sample show how property bags can be used. For an example of using property bags in a DTC, you can find a sample using the Code Sample Summary.
Note Often, choices are bound based on their type and text, where the type is fixed and the text is entered by the user. In this case, the text needs to be persisted, while the type does not.
When writing a handler in the OnChoiceChange method, changing any property or tag of a choice while in this handler can cause an infinite loop in the ChoicesEngine. By default, a DTC can read choices published by DTCs positioned before it in the document. You can change this by setting the Sequential property on a Choice and making it visible to DTCs above it and below it on a page. Allowing choices to be visible to all design-time controls in the document can lead to cyclical references. For example, you can create three DTCs and make the first rely on a choice in the third control, which relies on a choice in the second control, which relies on the first control. This creates an infinite loop that stalls the hosting editor.
Be careful when calling the ShowObjectProperty. Avoid creating loops in the object model. These loops cause the hosting editor to freeze. For example, if you have a node in the object model that refers to itself or one of its ancestors, a loop is created. For a sample of a DTC exposing an object model, see the Code Sample Summary.
The following example shows such a loop.
rcia.ShowObjectProperty "myTextobj", rcia
Note If you paste code from help topics into your project file, be sure to select the line above and below the entire code sample. Otherwise the text you paste loses the formatting it had while in the help topic.
By default, a DTC can read choices published by DTCs positioned before it in the document. If you changed this by setting the Sequential property on a Choice and made it visible to DTCs above it and below it on a page, your DTCs may have cyclical references. For example, you can create three DTCs and make the first rely on a choice in the third control, which relies on a choice in the second control, which relies on the first control. This creates an infinite loop that stalls the hosting editor.
When the editor prints the document, it is actually printing a new instance of the DTC and not the one that has the selected choices in the editor.
Be sure you have properly registered the control. For more information, see Registering a Visual Basic Control for Testing.