Implementing the Persistence Interfaces

The visual designer must support IPersist and one or more of its derived interfaces: IPersistStreamInit, IPersistStream, and IPersistStorage.

The IPersist interface is the base interface for the other three interfaces. It has one method, GetClassID, which returns the class identifier of an object that implements one or more of the other persistence interfaces. For an ActiveX designer, this method should return the class identifier (CLSID) of the visual designer.

Which of the derived persistence interface(s) you're required to implement depends on the type and size of the run-time objects you expect to be built from your ActiveX designer, and on which hosts will use it.

Hosts request a persistence interface by iteratively calling QueryInterface on the ActiveX designer object, passing interface identifiers (IIDs) in order of preference. Different hosts may request different persistence interfaces. In general, IPersistStreamInit is the preferred interface because it is the fastest and because its InitNew method allows the object to avoid loading itself twice (once when the instance is created and again when the Load method is called). IPersistStream is fast, but because it does not include an InitNew method, it lacks the advantage of this loading optimization. Some hosts, however, use IPersistStorage. Although storage persistence requires significantly more overhead, some applications need structured storage, and some subobjects require it.

In the visual designer, you may also want to implement IPersistPropertyBag, which saves information about properties and methods in a textual format. See the COM Programmer’s Reference in the Platform Software Development Kit (SDK) for more information.