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.
#include "StdAfx.h"
#include "vseditorfactory.h"
#include "ServiceProvider.h"
#include "DocView.h"

START_IMPL_SPY(IVsEditorFactory,7)

//SPY_STUB_(0,"    IVsEditorFactory")
STDMETHODIMP EF_QueryInterface(void* pThat, REFIID riid, void **ppObj)
{
	CDbg::Trace( "     IVsEditorFactory::QueryInterface(0x%p, riid=\n", pThat );
	CDbg::TraceGuid( riid );
	CDbg::TraceC( ", [out] ppObj (0x%p) )\n", ppObj );

	HRESULT hr;// = m_pRealObject->QueryInterface( riid, ppObj );
	CALL_METHOD3(0,pThat,riid,ppObj);
	GET_RET_VAL(hr);

	CDbg::Trace( "     IVsEditorFactory::QueryInterface(,[out] *ppObj=0x%p\n) = %X", *ppObj, hr );
	return hr;
}



SPY_STUB_SILENT(1)//,"    IVsEditorFactory")
SPY_STUB_SILENT(2)//,"    IVsEditorFactory")


//SPY_STUB_(3,"    IVsEditorFactory")
STDMETHODIMP EF_CreateEditorInstance(void* pThat, DWORD dwFlg, LPCOLESTR pszDoc, LPOLESTR pszView,
									 void* pvHier, DWORD dwID, IUnknown* pDocDataExisting,
									 IUnknown** ppDocView, IUnknown** ppDocData, BSTR* pbsCapt,
									 GUID*	pguidCmdUI, void* pCDW )
{
	CDbg::Trace( "     IVsEditorFactory::CreateEditorInstance(0x%p,\n", pThat );
	CDbg::Trace( "                          flag=%X, pszDoc=%S(0x%p), pszView=%S,\n", dwFlg, pszDoc, pszDoc, pszView ); 
	CDbg::Trace( "                          pvHier=0x%p, ID=%d, pDocExist=0x%p\n", pvHier, dwID, pDocDataExisting );
	CDbg::Trace( "			                [out]ppDocView (0x%p), [out]ppDocData (0x%p), [out]pbsCapt (0x%p),\n",
											ppDocView,  ppDocData, pbsCapt );
	CDbg::Trace( "			                [out]pguidCmdUI (0x%p), [out]pCDW (0x%p) )\n", pguidCmdUI, pCDW );

	HRESULT hr;
	__asm{ push pCDW }
	__asm{ push pguidCmdUI }
	__asm{ push pbsCapt }
	__asm{ push ppDocData }
	__asm{ push ppDocView }
	__asm{ push pDocDataExisting }
	__asm{ push dwID }
	__asm{ push pvHier }
	CALL_METHOD4(3,pThat,dwFlg,pszDoc,pszView);
	GET_RET_VAL(hr);

	if ( hr == S_OK )
	{
		SET_SPY(IUnknownDocView,*ppDocView);
		CDbg::Trace( "<------------->IDocView subclassed: obj = 0x%p\n", *ppDocView );
		SET_SPY(IUnknownDocData,*ppDocData);
		CDbg::Trace( "<------------->IDocData subclassed: obj = 0x%p\n", *ppDocData );
	}

	CDbg::Trace( "     IVsEditorFactory::CreateEditorInstance(,,..,,[out]*ppDocView=0x%p,\n", *ppDocView );
	CDbg::Trace( "                            [out]*ppDocData=0x%p, [capt], [out]CommndGuid=", *ppDocData );
	CDbg::TraceGuid( *pguidCmdUI );
	CDbg::TraceC( ",  ) = %x\n", hr );

	return hr;
}


//SPY_STUB_(4,"    IVsEditorFactory")
STDMETHODIMP EF_Stub4( void* pThat, IServiceProvider* pSP )
{
	HRESULT hr;
	CDbg::Trace( "     IVsEditorFactory::Stub4(0x%p, (IServiceProvider)pSP=%p )\n", pThat, pSP );
	
	CServiceProvider* pMySP = new CServiceProvider;

	if ( pMySP && pMySP->Attach(pSP) )
	{
		// i'm not sure that pSP need to be wrapped, probably it was already subclassed-check pointers
		CDbg::Trace( "<-----???----->IServiceProvider wrapped: orig=0x%p, new=0x%p\n", pSP, pMySP );
		pSP = pMySP;
	}

	CALL_METHOD2(4,pThat,pSP);
	GET_RET_VAL(hr);
	CDbg::Trace( "     IVsEditorFactory::Stub4() = %x\n", hr );
	
	return hr;
}


//SPY_STUB_(5,"    IVsEditorFactory")
STDMETHODIMP EF_Stub5( void* pThat )
{
	CDbg::Trace( "     IVsEditorFactory::Stub5(0x%p)\n", pThat );
	HRESULT hr;
	CALL_METHOD1(5,pThat);
	GET_RET_VAL(hr);
	CDbg::Trace( "     IVsEditorFactory::Stub5( ) = %x\n", hr );
	return hr;
}



//SPY_STUB_(6,"    IVsEditorFactory")
STDMETHODIMP EF_Stub6( void* pThat, void* p1, void* p2)
{
	CDbg::Trace( "     IVsEditorFactory::Stub6(0x%p, p1=0x%p, p2=0x%p ) = S_OK\n", pThat, p1, p2 );
	return S_OK;
}

SPY_START_VTBL(7)
	SPY_ENTRY_(EF_QueryInterface,0)
	SPY_ENTRY(1)
	SPY_ENTRY(2)
	//SPY_ENTRY(3)
	SPY_ENTRY_(EF_CreateEditorInstance,3)
	//SPY_ENTRY(4)
	SPY_ENTRY_(EF_Stub4,4)
	SPY_ENTRY_(EF_Stub5, 5)
	//SPY_ENTRY(6)
	SPY_ENTRY_(EF_Stub6,6)
SPY_END_VTBL()

END_IMPL_SPY()

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

Share

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 | Terms of Use | Mobile
Web01 | 2.8.150326.1 | Last Updated 21 Dec 2003
Article Copyright 2003 by Michael Sheinin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid