How to: Provide Automation for Windows
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at 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.
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
Call the GetProperty method via the environment with VSFPROPID_ExtWindowObject as
VSFPROPIDparameter to get theWindowobject.When a caller requests a VSPackage-specific automation object for your tool window through Object, the environment calls
QueryInterfaceforIExtensibleObject, IVsExtensibleObject, or theIDispatchinterfaces. BothIExtensibleObjectandIVsExtensibleObjectprovide a GetAutomationObject method.When the environment then calls the
GetAutomationObjectmethod passingNULL, respond by passing back your VSPackage-specific object.If calling
QueryInterfaceforIExtensibleObjectandIVsExtensibleObjectfails, then the environment callsQueryInterfaceforIDispatch.
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 VSSDK Samples contributes an RTF document-specific automation object.