⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connect.h

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 H
字号:
/************************************************************************
 *
 *            Resource ID Organiser Add-In for Visual C++
 *
 * (c) Copyright 2000-2005 by Riverblade Limited (UK). All rights reserved.
 *
 ************************************************************************
 *
 *  Description : CConnect class - primary interface to Visual Studio
 *
 *  Compiler    : Microsoft Visual C++ .NET 2003
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 2000/XP/Vista;
 *                Visual Studio 2002, 2003 or 2005
 *  NOTE:
 *
 *    This software is provided "as is". All title and copyrights in and
 *    to the software, including but not limited to any images, text etc.
 *    etc. incorporated into it, are the property of Anna-Jayne Metcalfe
 *    and Riverblade Limited, except where acknowledged otherwise.
 *
 *    Your may freely use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *    Please visit http://www.riverblade.co.uk/products/resorg or email
 *    support@riverblade.co.uk for latest updates and product support 
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgNETAddIn/Connect.h $
 *   $Revision: 16 $
 *       $Date: 22/10/05 11:12 $
 *     $Author: Anna $
 *
 *    $History: Connect.h $
 * 
 * *****************  Version 16  *****************
 * User: Anna         Date: 22/10/05   Time: 11:12
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Integrated ATL CMainToolWindowCtrl, which replaces the original MFC OLE
 * Control [IMS ID 125]
 * 
 * *****************  Version 15  *****************
 * User: Anna         Date: 17/10/05   Time: 20:20
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Started integrating CAddInCommandHandler classes
 * 
 * *****************  Version 14  *****************
 * User: Anna         Date: 13/10/05   Time: 12:55
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Modified #imports for DTE and MSO to import smart pointer interfaces as
 * well as raw ones.
 * 
 * *****************  Version 13  *****************
 * User: Anna         Date: 28/12/04   Time: 9:40
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * 1.  Added satellite DLL
 * 2.  Added icon to toolwindow
 * 3.  Minor mods for stability
 * 4.  Updated banner
 * 
 * *****************  Version 12  *****************
 * User: Anna         Date: 20/12/04   Time: 10:13
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * 1.  Changed the initialisation sequence to attempt to make it more
 * reliable
 * 2.  Added event unadvise during OnDisconnection()
 * 3.  Added icon to the toolwindow
 * 
 * *****************  Version 11  *****************
 * User: Anna         Date: 25/11/02   Time: 15:27
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Changed website address in banner
 * 
 * *****************  Version 10  *****************
 * User: Anna         Date: 22/10/02   Time: 14:15
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Changed name/email address (at last!)
 * 
 * *****************  Version 9  *****************
 * User: Andy         Date: 10/08/02   Time: 22:21
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * 1.  Fixed OnConnection() code...commands are now only setup if the
 * add-in has just been installed or manually reloaded
 * 2.  Tidied up the code
 * 
 * *****************  Version 8  *****************
 * User: Andy         Date: 10/08/02   Time: 0:16
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * 1.  Added groups to the toolbar (to make it wider so the caption would
 * fit!)
 * 2.  Fixed a window parenting problem when the main window of ResOrg was
 * opened on an expired version
 * 
 * *****************  Version 7  *****************
 * User: Andy         Date: 9/08/02    Time: 17:02
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Added "Options" and "AboutBox" commands
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 7/08/02    Time: 22:15
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Improved the way menu commands are added
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 6/08/02    Time: 10:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Removed unused code
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 5/08/02    Time: 13:49
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * 1.  Moved menu entries to a submenu under the Tools menu
 * 2.  Tidied up the code a little
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 1/08/02    Time: 16:44
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
 * Further development of ResOrg.NET - particularly the tool window
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 7/06/02    Time: 22:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddInVc7
 * Initial integration
 * 
 * *****************  Version 1  *****************
 * User: Andy         Date: 3/06/02    Time: 16:53
 * Created in $/Projects/AddIns/ResOrg/ResOrgAddInVc7
 *
 * $Nokeywords: $
 *
 ************************************************************************/

#pragma once

#include "ResOrgNETAddIn_Res.h"

#include "AddInCommandManager.h"
#include "AddInWindowManager.h"



#pragma warning( disable : 4278 )
//The following #import imports DTE based on it's LIBID
//#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids
#pragma warning( default : 4278 )

// CConnect
class ATL_NO_VTABLE CConnect : 
			public CComObjectRootEx<CComSingleThreadModel>,
			public CComCoClass<CConnect, &CLSID_Connect>,
			public IDispatchImpl<EnvDTE::IDTCommandTarget, &EnvDTE::IID_IDTCommandTarget, &EnvDTE::LIBID_EnvDTE, 7, 0>,
			public IDispatchImpl<AddInDesignerObjects::_IDTExtensibility2, &AddInDesignerObjects::IID__IDTExtensibility2, &AddInDesignerObjects::LIBID_AddInDesignerObjects, 1, 0>
{
// Construction/destruction
public:
			CConnect(void);

			~CConnect(void);

			
// ATL/COM stuff
DECLARE_REGISTRY_RESOURCEID(IDR_ADDIN)
DECLARE_NOT_AGGREGATABLE(CConnect)

BEGIN_COM_MAP(CConnect)
	COM_INTERFACE_ENTRY(AddInDesignerObjects::IDTExtensibility2)
	COM_INTERFACE_ENTRY(EnvDTE::IDTCommandTarget)
	COM_INTERFACE_ENTRY2(IDispatch, AddInDesignerObjects::IDTExtensibility2)
END_COM_MAP()


// Attributes
protected:
			CComPtr<EnvDTE::_DTE>	m_pDTE;
			CComPtr<EnvDTE::AddIn>	m_pAddInInstance;
			CComPtr<IMainToolWindowCtrl>	m_pMainToolWindowCtrl;
			HWND					m_hwndResOrg;
			CAddInCommandManager	m_CommandManager;
			CAddInWindowManager	m_WindowManager;
			EnvDTE::WindowPtr m_ptrMainToolWindow;
			

// Operations
public:
			DECLARE_PROTECT_FINAL_CONSTRUCT()

			HRESULT					FinalConstruct(void);
			void					FinalRelease(void);

// Interfaces
public:
			// IDTExtensibility2 implementation:
			STDMETHOD(OnConnection)		(IDispatch* pApplication,
										 AddInDesignerObjects::ext_ConnectMode eConnectMode,
										 IDispatch* pAddInInst,
										 SAFEARRAY** ppCustom);

			STDMETHOD(OnDisconnection)	(AddInDesignerObjects::ext_DisconnectMode eRemoveMode,
										 SAFEARRAY** custom );

			STDMETHOD(OnAddInsUpdate)	(SAFEARRAY** custom );

			STDMETHOD(OnStartupComplete)(SAFEARRAY** custom );

			STDMETHOD(OnBeginShutdown)	(SAFEARRAY** custom );

			
			// IDTCommandTarget implementation:
			STDMETHOD(raw_QueryStatus)	(BSTR CmdName,
										 EnvDTE::vsCommandStatusTextWanted eNeededText,
										 EnvDTE::vsCommandStatus* pStatusOption,
										 VARIANT* pCommandText);

			STDMETHOD(raw_Exec)			(BSTR CmdName,
										 EnvDTE::vsCommandExecOption eExecuteOption,
										 VARIANT* pVariantIn,
										 VARIANT* pVariantOut,
										 VARIANT_BOOL* pbHandled);

	// Implementation
protected:
			HRESULT					ConfigureEvents(void);
			HRESULT					UnadviseEvents(void);

			HRESULT					RefreshMainToolWindow(void);

			void					ConnectApp(void);

			void					DisconnectApp(void);



	// I found this code in the MS VCEvents sample. All I can say is YUCK!
	class SolutionEventsSink : public IDispEventImpl<	1,
														SolutionEventsSink,
														&__uuidof(EnvDTE::_dispSolutionEvents),
														&EnvDTE::LIBID_EnvDTE,
														7,
														0>
	{
	protected:
			CComPtr<IMainToolWindowCtrl>	m_pMainToolWindowCtrl;


	public:
		BEGIN_SINK_MAP(SolutionEventsSink)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 1, Opened)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 2, BeforeClosing)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 3, AfterClosing)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 4, QueryCloseSolution)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 5, Renamed)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 6, ProjectAdded)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 7, ProjectRemoved)
			SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispSolutionEvents), 8, ProjectRenamed)
		END_SINK_MAP()

		bool					OnConnection(CComPtr<IMainToolWindowCtrl> pMainToolWindowCtrl)
		{ m_pMainToolWindowCtrl = pMainToolWindowCtrl; return true; }

		void					OnDisconnection(void)
		{ m_pMainToolWindowCtrl = NULL; }

		HRESULT					RefreshMainToolWindow(void);

		void __stdcall Opened(void);
		void __stdcall BeforeClosing(void);
		void __stdcall AfterClosing(void);
		void __stdcall QueryCloseSolution(VARIANT_BOOL* fCancel);
		void __stdcall Renamed(BSTR bsOldName);
		void __stdcall ProjectAdded(EnvDTE::Project* pProject);
		void __stdcall ProjectRemoved(EnvDTE::Project* pProject);
		void __stdcall ProjectRenamed(EnvDTE::Project* pProject, BSTR bsOldName);

};
		SolutionEventsSink		m_SolutionEventsSink;
};


OBJECT_ENTRY_AUTO(__uuidof(Connect), CConnect)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -