|
// 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.
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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.