Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Customized Visual Studio .NET package: your fully integrated document window inside the IDE

, 20 Dec 2003
Create a fully integrated document window inside the Visual Studio IDE.
/**********************************************************************
- File Name: VsRegisterEditors.cpp
- Date: 12/7/2003 6:29:18 PM
- Author: Michael Sheinin
- Description : 
	Implementation of CVsRegisterEditors class.
- Notes: 
	-The method RegisterEditor() is called by the original "bined.dll" package.
	The method is passed a IVsEditorFactory object as a parameter. The object
	is wrapped by a CVsEditorFactory class object and then it is returned to
	V-Studio instead of "bined" supplied one.
	-Function NoName is called on V-Studio termination and probably is named
	"UnregisterEditor".
**********************************************************************/
#include "StdAfx.h"

#include "VsRegisterEditors.h"
#include "VsEditorFactory.h"


STDMETHODIMP_(ULONG) CVsRegisterEditors::AddRef()
{
	if ( m_pRealObject )
	{
		return m_pRealObject->AddRef();
	}
	return 0;
}

STDMETHODIMP_(ULONG) CVsRegisterEditors::Release()
{
	if ( m_pRealObject )
	{
		return m_pRealObject->Release();
	}
	return 0;
}
BOOL CVsRegisterEditors::Attach(IVsRegisterEditors* pObj)
{
	if ( m_pRealObject == pObj )
	{
		return TRUE;
	}
	if ( m_pRealObject == NULL )
	{
		m_pRealObject = pObj;
		return TRUE;
	}
	return FALSE;
}

STDMETHODIMP CVsRegisterEditors::QueryInterface(REFIID riid, void **ppObj)
{
	CDbg::Trace( "    IVsRegisterEditors::QueryInterface( riid=" );
	CDbg::TraceGuid( riid );
	CDbg::TraceC( ", [out] ppObj=0x%p )\n", ppObj );
	HRESULT hr = m_pRealObject->QueryInterface( riid, ppObj );
	CDbg::Trace( "    IVsRegisterEditors::QueryInterface(, [out] *ppObj=0x%p ) = %X\n", *ppObj, hr );
	return hr;
}

STDMETHODIMP CVsRegisterEditors::RegisterEditor( REFIID riid, void* pObj, DWORD* pdwCookie )
{
	if ( m_pRealObject )
	{
		CDbg::Trace( "    IVsRegisterEditors::RegisterEditor( riid=" );
		CDbg::TraceGuid( riid );
		CDbg::TraceC( ", pObj=0x%p, *cookie=%X (0x%p) )\n", pObj, *pdwCookie, pdwCookie );

		CVsEditorFactory* pEF = new CVsEditorFactory();
		
		HRESULT hr;
		if ( pEF && pEF->Attach(pObj) )
		{
			CDbg::Trace( "<------------->IVsEditorFactory wrapped: obj = 0x%p, new=0x%p\n", pObj, pEF );
			hr = m_pRealObject->RegisterEditor(riid,pEF,pdwCookie);
		}
		else
		{
			if ( pEF )
			{
				delete pEF;
			}
			hr = m_pRealObject->RegisterEditor(riid,pEF,pdwCookie);
		}
		
		CDbg::Trace( "    IVsRegisterEditors::RegisterEditor(, *cookie=%X (0x%p) )\n", *pdwCookie, pdwCookie );
	}
	return E_INVALIDARG;
}


STDMETHODIMP CVsRegisterEditors::NoName( DWORD dwCookie )
{
	HRESULT hr = E_INVALIDARG;

	if ( m_pRealObject )
	{
		CDbg::Trace( "    IVsRegisterEditors::Stub4( dwCookie=0x%x )\n", dwCookie );
		hr = m_pRealObject->NoName( dwCookie );

		CDbg::Trace( "    IVsRegisterEditors::Stub4( ) = %X\n", hr );
	}
	return hr;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Michael Sheinin
Web Developer
United States United States
For the last 7 years I have developed software in real-time/embedded and MS-Windows environments for military and civil markets. I hold B.Sc. degree in computer engineering. Living in Ontario, Canada, I like hiking and traveling in general. Currently, I'm looking for employment opportunity inside the GTA.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 21 Dec 2003
Article Copyright 2003 by Michael Sheinin
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid