At design time, an ActiveX designer can access some of the host's ambient properties. Through these read-only properties, the designer can get information from the host about the project status. A designer accesses the properties through a site pointer to the host's IDispatch::Invoke method, as for ActiveX controls.
The DISPID_AMBIENT_BUILDDIRECTORY property returns a VT_BSTR string specifying the fully qualified name of the directory that contains the current compiled project files. If the user has not compiled the project, this property returns an empty string ("").
The DISPID_AMBIENT_CLSID property returns a VT_BSTR string containing the CLSID of the public run-time object being authored. This property is available only to designers that can be public, that is, designers that set DESIGNERFEATURE_CANBEPUBLIC.
The DISPID_AMBIENT_INTERACTIVE property returns a VT_BOOL value. The value of the property is VARIANT_TRUE if the design-time object is visible to the user, and VARIANT_FALSE if the host has merely created a temporary instance of the designer.
If the designer is not loaded, the host can create a temporary instance to get information from the designer or to notify the designer in response to a previous request. For example, the host can create a temporary instance when it needs to get the designer's type information or when it calls one of the following designer methods:
If the instance is temporary, the designer does not need to initialize and present its user interface, and therefore may be able to optimize its loading process.
Designers should check this value during initialization. The value remains constant for the lifetime of the designer instance.
The DISPID_AMBIENT_PROGID property returns a VT_BSTR string containing the programmatic ID (PROGID) of the public run-time object the user is authoring. For example, this property would return "Project1.MyDesigner1" for the MyDesigner1 instance of a designer named MyDesigner, in a host project named Project1.
This property is available only to designers that can be public, that is, designers that set DESIGNERFEATURE_CANBEPUBLIC.
The DISPID_AMBIENT_PROJECTDIRECTORY property returns a VT_BSTR string specifying the fully qualified name of the directory that contains the current host project files. If the user has not saved the project, this property returns an empty string ("").
The DISPID_AMBIENT_SAVEMODE property returns an enumerator (type VT_I4) that describes how the designer is currently being saved. The following table lists the possible enumerators:
Enumerator | Meaning |
DESIGNERSAVEMODE_NORMAL | The host is saving the designer in the user's project files. This value means that the user has saved the designer by clicking Save on the File menu or requesting its equivalent. |
DESIGNERSAVEMODE_EXE | The host is compiling the project and therefore is saving the designer in a .DLL or .EXE file. |
DESIGNERSAVEMODE_TEMPORARY | The host is saving the designer in a temporary file. Visual Basic saves the designer in temporary storage before it runs the designer in the IDE. |
The value of this property is valid only in the scope of the designer's IActiveDesigner::SaveRuntimeState method or in the Save method of the designer's persistence interface.