Share via


How to: Provide Automation for Windows

You can provide automation for document and tool windows. Providing automation is advisable whenever you want to make automation objects available on a window, and the environment does not already provide a ready-made automation object, as it does with a task list.

Automation for Tool Windows

The environment provides automation on a tool window by returning a standard Window object as explained in the following procedure:

To provide automation for tool windows

  1. Call the GetProperty method via the environment with VSFPROPID_ExtWindowObject as VSFPROPID parameter to get the Window object.

  2. When a caller requests a VSPackage-specific automation object for your tool window through Object, the environment calls QueryInterface for IExtensibleObject, IVsExtensibleObject, or the IDispatch interfaces. Both IExtensibleObject and IVsExtensibleObject provide a GetAutomationObject method.

  3. When the environment then calls the GetAutomationObject method passing NULL, respond by passing back your VSPackage-specific object.

  4. If calling QueryInterface for IExtensibleObject and IVsExtensibleObject fails, then the environment calls QueryInterface for IDispatch.

Automation for Document Windows

A standard Document object is also available from the environment, although an editor can have its own implementation of the T:EnvDTE.Document object by implementing IExtensibleObject interface and responding to GetAutomationObject.

In addition, an editor can provide a VSPackage-specific automation object, retrieved through the Object method, by implementing the IVsExtensibleObject or IExtensibleObject interfaces. The Basic Edit sample contributes an RTF document-specific automation object.

See Also

Reference

IVsExtensibleObject

Other Resources

Basic Edit