Creating Public Objects

With an ActiveX designer, a user can create objects that are public and therefore can be registered and possibly used by other applications. The following DesignerFeatures flags in the registry control how the host creates and exposes the objects:

By default, designer run-time objects are private. They can be created and exposed only within the host's name space.

To allow the run-time object to be exposed outside the host's name space, specify the DESIGNERFEATURE_CANBEPUBLIC flag. Use this flag when the designer can be useful both inside and outside the host's name space. If the host exposes the designer, other applications can use its public properties and methods. If the host does not expose the designer, however, its properties and methods are accessible only within the host's name space.

The run-time object can expose properties and methods only to user code implementing its events; it cannot expose any properties or methods that are public. However, the run-time object can publicly expose other COM interfaces.

To require that the run-time designer be exposed outside the host's name space, specify both the DESIGNERFEATURE_CANBEPUBLIC and the DESIGNERFEATURE_MUSTBEPUBLIC flags. Use these flags when the designer must be public to be of use. When you specify both flags, the host disables use of the designer if it cannot be exposed. For example, a designer that must be created at run time by Internet Explorer in order to be useful would specify both these flags.

To allow the designer to be created outside the host's name space, specify the DESIGNERFEATURE_CANCREATE flag. Use this flag when the designer appears in the type library and can be created with ITypeInfo::CreateInstance. Combining this flag with DESIGNERFEATURE_CANBEPUBLIC is equivalent to setting the Instancing property to Multiuse for a Visual Basic class module. You must also set DESIGNERFEATURE_CANCREATE to allow a public designer class to be created with the New keyword in Visual Basic.

In addition, you can require that a designer be used only with an in-process server. Setting the DESIGNERFEATURE_INPROCONLY flag means that the designer can be run only in the same process as its host. It cannot be used with cross-thread, cross-process, or cross-machine marshaling. For example, a user cannot add the designer to a Visual Basic project that creates an .EXE project.