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
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use, compile or redistribute this source as part of your application 
// for free. You may not redistribute it as a part of a software development 
// library without the agreement of the author. If the sources are 
// distributed along with the application, you should leave the original 
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
// 
// Nick Hodapp
// nhodapp@codeveloper.com
//
//*******************************************************************************

// DSAddin.cpp : Implementation of COpenVC
#include "stdafx.h"
#include "OpenVC.h"
#include "OpenVCAddin.h"

/////////////////////////////////////////////////////////////////////////////
// COpenVC


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

STDMETHODIMP COpenVC::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,
					 bstrDeleteNCB = "DeleteNCB",
					 bstrShowInnards = "ShowInnards";

	// DeleteNCB
	bstrCmd = "DeleteNCB\nDeleteNCB\nDeletes corrupt NCB files.\nDeleteNCB";
	if (FAILED(piApplication->AddCommand(bstrCmd, bstrDeleteNCB, 0, dwCookie, &bRet) || VARIANT_FALSE == bRet))
		return S_OK;

	// ShowInnards
	bstrCmd = "ShowInnards\nShowInnards\nA Sample Addin Command\nShowInnards";
	if (FAILED(piApplication->AddCommand(bstrCmd, bstrShowInnards, 1, dwCookie, &bRet) || VARIANT_FALSE == bRet))
		return S_OK;


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

	// success
	*pbOnConnection = VARIANT_TRUE;

	return S_OK;
}

STDMETHODIMP COpenVC::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

About the Author

Nick Hodapp
Web Developer
United States United States
No Biography provided

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