Adding an Instance of an ActiveX Designer

To add an instance of an ActiveX designer to a project, the end user clicks the name of the designer on the Project menu or the More ActiveX Designers pop-up. In response, Visual Basic adds a Designers folder to the Project hierarchy (shown in the Project window) and takes the following steps:

  1. Creates a visual designer object. Visual Basic calls CoCreateInstance, passing the CLSID of the visual designer, to create the visual object. The designer's class factory ensures that any required licenses are present, and if so, creates the object.

  2. Initializes the visual designer. Visual Basic calls the designer's IOleObject::SetClientSite method to associate the designer with a site. Then it calls the InitNew or Init method of the designer's persistence interface to load the designer's persistent data.

  3. Displays the visual designer. Visual Basic provides a frame and uses ActiveX and COM interfaces to display the user interface.

If the designer sets the DESIGNERFEATURE_PREDECLAREDID flag in the registry, Visual Basic creates a default instance of the visual designer. See Chapter 11, "Registry Reference," for details.

After Visual Basic creates and initializes the designer, the designer can use the SDesignerToolboxSite service to add items to the Visual Basic toolbox. See Chapter 4, "Interaction Between ActiveX Designer and Host," for details.