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

Undocumented Visual C++

, 17 Sep 2000
Spelunking in the Badlands of MSDEV
// DSAddin.cpp : Implementation of C$$ADDIN_OBJNAME$$
#include "stdafx.h"
#include "$$root$$.h"
#include "$$ADDIN_OBJNAME$$Addin.h"

/////////////////////////////////////////////////////////////////////////////
// C$$ADDIN_OBJNAME$$


///////////////////////////////////////////////////////////////////////////////
// IDSAddin

STDMETHODIMP C$$ADDIN_OBJNAME$$::OnConnection(IApplication* piApplication, VARIANT_BOOL bFirstTime, long dwCookie, VARIANT_BOOL* pbOnConnection)
{
	// prepare to fail!
	*pbOnConnection = VARIANT_FALSE;

	// create our command object
	CCommandsObj::CreateInstance(&m_pCommands);
	m_pCommands->AddRef();
	m_pCommands->m_piApplication = piApplication;
	CComQIPtr<IDispatch> piDispCmds = m_pCommands;

	// tell VC about us:
	if (FAILED(piApplication->SetAddInInfo((long)_Module.GetModuleInstance(), piDispCmds, IDR_TOOLBAR_MEDIUM, IDR_TOOLBAR_LARGE, dwCookie)))
		return S_OK;

	// register our commands with VC
	VARIANT_BOOL bRet;
	_bstr_t		 bstrCmd,
					 bstrSampleCommand = "SampleCommand";

	// SampleCommand
	bstrCmd = "SampleCommand\nSampleCommand\nA Sample Addin Command\nSampleCommand";
	if (FAILED(piApplication->AddCommand(bstrCmd, bstrSampleCommand, 0, dwCookie, &bRet) || VARIANT_FALSE == bRet))
		return S_OK;

	// create toolbar:
	if (VARIANT_TRUE == bFirstTime)
	{
		piApplication->AddCommandBarButton(dsGlyph, bstrSampleCommand, dwCookie);
	}

	// success
	*pbOnConnection = VARIANT_TRUE;

	return S_OK;
}

STDMETHODIMP C$$ADDIN_OBJNAME$$::OnDisconnection(VARIANT_BOOL bLastTime)
{
	// cleanup!
	m_pCommands->Release();
	m_pCommands = NULL;

	return S_OK;
}

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

Nick Hodapp
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 18 Sep 2000
Article Copyright 2000 by Nick Hodapp
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid