Using VTBL Interfaces in Run-Time Designers

An ActiveX designer can use a dispatch interface, a VTBL interface, or a dual interface (which combines both dispatch and VTBL features). Using VTBL and dual interfaces can benefit performance; see the Automation Programmer's Referencein the Platform Software Development Kit (SDK) for complete information. This section outlines special requirements for ActiveX designers that implement VTBL interfaces.

To support a VTBL interface, a designer must:

To create a VTBL of adequate size, the designer must either create the VTBL dynamically in memory at run time or, at compile time, create a VTBL large enough for all the items a user might add to the type information. The run-time object must implement the interfaces.

If you can't make any predictions about the amount of type information a user might add, or if imposing an arbitrary limit on this number is impractical, you'll probably have to create the VTBL dynamically in memory at run time.

If you can predict or limit the number of items a user will add to the object's type information, you can create a VTBL at design time.

One way to implement this approach is to create two interfaces in the run-time object. The first contains all the static properties and methods of the interface, and the second, derived from the first, contains the dynamically added properties and methods. Then you can declare the maximum number property Get and Put methods in the derived interface. Your code supplies generic names for the dynamic properties and methods, but these properties and methods return different values and perform different actions for each authored run-time object.

For example, if you can limit the total number of added properties and methods to 64, and you know that the VTBL will be created only once for all the designers of that class running on your server, you can set up a VTBL with entries for 64 property gets and 64 property puts. At compile time, you'll create a VTBL large enough for the maximum.

Visual Basic also supports dispatch and VTBL (but not dual) interfaces for event sources. If your ActiveX designer uses VTBL interfaces for event sources, it should check that the VTBL entry is not NULL before it fires an event. For designer events to which user code is attached, the corresponding entry in the VTBL contains a valid pointer. However, if the Visual Basic programmer does not attach any user code to a designer event, Visual Basic places NULL in the corresponding entry in the VTBL.