Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
6.5 KiB

  1. // Connect.h : Declaration of the CConnect
  2. #pragma once
  3. #include "resource.h" // main symbols
  4. #include <set>
  5. #pragma warning( disable : 4278 )
  6. #include "dte.tlh"
  7. #pragma warning( default : 4278 )
  8. // CConnect
  9. class CConnect :
  10. public CComObjectRootEx<CComSingleThreadModel>,
  11. public CComCoClass<CConnect, &CLSID_Connect>,
  12. public IDispatchImpl<EnvDTE::IDTCommandTarget, &EnvDTE::IID_IDTCommandTarget,
  13. &EnvDTE::LIBID_EnvDTE, 7, 0>,
  14. public IDispatchImpl<AddInDesignerObjects::_IDTExtensibility2,
  15. &AddInDesignerObjects::IID__IDTExtensibility2,
  16. &AddInDesignerObjects::LIBID_AddInDesignerObjects, 1, 0>
  17. {
  18. public:
  19. CConnect()
  20. {
  21. }
  22. private:
  23. void CreatePropertySheet(HWND hWndParent);
  24. static BOOL CALLBACK DlgViewOptions(
  25. HWND hDlg,
  26. UINT message,
  27. WPARAM wParam,
  28. LPARAM lParam
  29. );
  30. HPROPSHEETPAGE* m_phPages;
  31. PROPSHEETPAGE m_PageGlobal;
  32. PROPSHEETHEADER m_psh;
  33. public:
  34. DECLARE_REGISTRY_RESOURCEID(IDR_ADDIN)
  35. DECLARE_NOT_AGGREGATABLE(CConnect)
  36. BEGIN_COM_MAP(CConnect)
  37. COM_INTERFACE_ENTRY(AddInDesignerObjects::IDTExtensibility2)
  38. COM_INTERFACE_ENTRY(EnvDTE::IDTCommandTarget)
  39. COM_INTERFACE_ENTRY2(IDispatch, AddInDesignerObjects::IDTExtensibility2)
  40. END_COM_MAP()
  41. DECLARE_PROTECT_FINAL_CONSTRUCT()
  42. HRESULT FinalConstruct()
  43. {
  44. return S_OK;
  45. }
  46. void FinalRelease()
  47. {
  48. }
  49. public:
  50. //IDTExtensibility2 implementation:
  51. STDMETHOD(OnConnection)(IDispatch * Application,
  52. AddInDesignerObjects::ext_ConnectMode ConnectMode,
  53. IDispatch *AddInInst, SAFEARRAY **custom);
  54. STDMETHOD(OnDisconnection)(AddInDesignerObjects::ext_DisconnectMode RemoveMode, SAFEARRAY **custom );
  55. STDMETHOD(OnAddInsUpdate)(SAFEARRAY **custom );
  56. STDMETHOD(OnStartupComplete)(SAFEARRAY **custom );
  57. STDMETHOD(OnBeginShutdown)(SAFEARRAY **custom );
  58. //IDTCommandTarget implementation:
  59. STDMETHOD(QueryStatus)(BSTR CmdName, EnvDTE::vsCommandStatusTextWanted NeededText,
  60. EnvDTE::vsCommandStatus *StatusOption, VARIANT *CommandText);
  61. STDMETHOD(Exec)(BSTR CmdName, EnvDTE::vsCommandExecOption ExecuteOption,
  62. VARIANT *VariantIn, VARIANT *VariantOut, VARIANT_BOOL *Handled);
  63. private:
  64. // Event sinks
  65. class CDTEEventsSink :
  66. public IDispEventImpl<1, CDTEEventsSink, &__uuidof(EnvDTE::_dispDTEEvents),
  67. &EnvDTE::LIBID_EnvDTE, 7, 0>
  68. {
  69. friend class CConnect;
  70. private:
  71. CConnect* m_pParent;
  72. public:
  73. CDTEEventsSink()
  74. {}
  75. BEGIN_SINK_MAP(CDTEEventsSink)
  76. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDTEEvents), 1, OnStartupComplete)
  77. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDTEEvents), 2, OnBeginShutdown)
  78. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDTEEvents), 3, ModeChanged)
  79. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDTEEvents), 4, OnMacrosRuntimeReset)
  80. END_SINK_MAP()
  81. void __stdcall OnStartupComplete()
  82. {
  83. }
  84. void __stdcall OnBeginShutdown()
  85. {
  86. }
  87. void __stdcall ModeChanged(EnvDTE::vsIDEMode LastMode)
  88. {
  89. ::MessageBox(NULL, TEXT("Mode changed!"),
  90. TEXT("Mode Changed!"), MB_OK);
  91. if (LastMode == EnvDTE::vsIDEModeDebug)
  92. {
  93. ::MessageBox(NULL, TEXT("Mode changed from dbg"),
  94. TEXT("Mode Changed!"), MB_OK);
  95. // Refresh log
  96. CComPtr<EnvDTE::Window> pWindow;
  97. pWindow = m_pParent->GetToolWindow(CLSID_LogViewer);
  98. if (pWindow)
  99. {
  100. CComPtr<IDispatch> pObj;
  101. HRESULT hr = pWindow->get_Object(&pObj);
  102. if (SUCCEEDED(hr))
  103. {
  104. CComQIPtr<ILogViewer, &__uuidof(ILogViewer)> pLogViewer;
  105. if (pLogViewer)
  106. {
  107. pLogViewer->Refresh();
  108. }
  109. }
  110. }
  111. }
  112. }
  113. void __stdcall OnMacrosRuntimeReset()
  114. {
  115. }
  116. };
  117. class CSolutionEventsSink :
  118. public IDispEventImpl<1, CSolutionEventsSink,
  119. &__uuidof(EnvDTE::_dispSolutionEvents), &EnvDTE::LIBID_EnvDTE, 7, 0>
  120. {
  121. friend class CConnect;
  122. private:
  123. CConnect* m_pParent;
  124. public:
  125. CSolutionEventsSink()
  126. {}
  127. BEGIN_SINK_MAP(CSolutionEventsSink)
  128. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 1, Opened)
  129. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 2, BeforeClosing)
  130. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 3, AfterClosing)
  131. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 4, QueryCloseSolution)
  132. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 5, Renamed)
  133. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 6, ProjectAdded)
  134. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 7, ProjectRemoved)
  135. SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 8, ProjectRenamed)
  136. END_SINK_MAP()
  137. HRESULT __stdcall AfterClosing();
  138. HRESULT __stdcall BeforeClosing();
  139. HRESULT __stdcall Opened();
  140. HRESULT __stdcall ProjectAdded(EnvDTE::Project* proj);
  141. HRESULT __stdcall ProjectRemoved(EnvDTE::Project* proj);
  142. HRESULT __stdcall ProjectRenamed(EnvDTE::Project* proj, BSTR bstrOldName);
  143. HRESULT __stdcall QueryCloseSolution(VARIANT_BOOL* fCancel);
  144. HRESULT __stdcall Renamed(BSTR bstrOldName);
  145. };
  146. CDTEEventsSink m_dteEventsSink;
  147. CSolutionEventsSink m_solutionEventsSink;
  148. CComPtr<EnvDTE::_DTE>m_pDTE;
  149. CComPtr<EnvDTE::AddIn>m_pAddInInstance;
  150. CComPtr<Office::CommandBarControl>m_pEnableControl;
  151. CComPtr<Office::CommandBarControl>m_pOptionControl;
  152. CComPtr<Office::CommandBarControl>m_pLogViewControl;
  153. CComPtr<Office::CommandBarControl>m_pTestsControl;
  154. bool m_bEnabled;
  155. CComPtr<EnvDTE::Window>GetToolWindow(CLSID clsid);
  156. void CreateToolWindow(const CLSID& clsid);
  157. void GetNativeVCExecutableNames(EnvDTE::Project* pProject);
  158. std::set<std::wstring>m_sExeList;
  159. BOOL GetAppExeNames();
  160. BOOL GetAppInfo();
  161. void SetEnabledUI();
  162. void SetDisabledUI();
  163. void ClearCurrentAppSettings();
  164. void SetCurrentAppSettings();
  165. void DisableVerificationBtn();
  166. void EnableVerificationBtn();
  167. };