// Connect.h : Declaration of the CConnect #pragma once #include "resource.h" // main symbols using namespace AddInDesignerObjects; using namespace EnvDTE; using namespace EnvDTE80;<%BEGIN VSCommand%> using namespace Microsoft_VisualStudio_CommandBars;<%END VSCommand%> /// The object for implementing an Add-in. /// class ATL_NO_VTABLE CConnect : public CComObjectRootEx, public CComCoClass, <%BEGIN VSCommand%>public IDispatchImpl,<%END VSCommand%> public IDispatchImpl<_IDTExtensibility2, &IID__IDTExtensibility2, &LIBID_AddInDesignerObjects, 1, 0> { public: /// Implements the constructor for the Add-in object. Place your initialization code within this method. CConnect() { } DECLARE_REGISTRY_RESOURCEID(IDR_ADDIN) DECLARE_NOT_AGGREGATABLE(CConnect) <%BEGIN VSCommand%>BEGIN_COM_MAP(CConnect) COM_INTERFACE_ENTRY(IDTExtensibility2) COM_INTERFACE_ENTRY(IDTCommandTarget) COM_INTERFACE_ENTRY2(IDispatch, IDTExtensibility2) END_COM_MAP()<%END VSCommand%> <%BEGIN NOT VSCommand%>BEGIN_COM_MAP(CConnect) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IDTExtensibility2) END_COM_MAP()<%END NOT VSCommand%> DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: //IDTExtensibility2 implementation: /// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded. /// Root object of the host application. /// Describes how the Add-in is being loaded. /// Object representing this Add-in. /// STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode ConnectMode, IDispatch *AddInInst, SAFEARRAY **custom); /// Implements the OnDisconnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being unloaded. /// Describes how the Add-in is being unloaded. /// Array of parameters that are host application specific. /// STDMETHOD(OnDisconnection)(ext_DisconnectMode RemoveMode, SAFEARRAY **custom ); /// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface. Receives notification when the collection of Add-ins has changed. /// Array of parameters that are host application specific. /// STDMETHOD(OnAddInsUpdate)(SAFEARRAY **custom ); /// Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading. /// Array of parameters that are host application specific. /// STDMETHOD(OnStartupComplete)(SAFEARRAY **custom ); /// Implements the OnBeginShutdown method of the IDTExtensibility2 interface. Receives notification that the host application is being unloaded. /// Array of parameters that are host application specific. /// STDMETHOD(OnBeginShutdown)(SAFEARRAY **custom ); <%BEGIN VSCommand%>//IDTCommandTarget implementation: /// Implements the QueryStatus method of the IDTCommandTarget interface. This is called when the command's availability is updated /// The name of the command to determine state for. /// Text that is needed for the command. /// The state of the command in the user interface. /// Text requested by the neededText parameter. /// STDMETHOD(QueryStatus)(BSTR CmdName, vsCommandStatusTextWanted NeededText, vsCommandStatus *StatusOption, VARIANT *CommandText); /// Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked. /// The name of the command to execute. /// Describes how the command should be run. /// Parameters passed from the caller to the command handler. /// Parameters passed from the command handler to the caller. /// Informs the caller if the command was handled or not. /// STDMETHOD(Exec)(BSTR CmdName, vsCommandExecOption ExecuteOption, VARIANT *VariantIn, VARIANT *VariantOut, VARIANT_BOOL *Handled);<%END VSCommand%> private: CComPtr m_pDTE; CComPtr m_pAddInInstance; }; OBJECT_ENTRY_AUTO(__uuidof(Connect), CConnect)