Click to See Complete Forum and Search --> : does ANYBODY ever written an Addin????


andreas75
March 26th, 2003, 05:04 AM
in VS.NET (c++)
seems, that nobody can help me :((
i have 3 main problems, i just cant solve, although they sound easy:

1. I cant change the icon of the addin button.(i always have the default button, a smiley)
(sounds like a easy problem,he? TRY IT!!!,change it to a custom icon!)

2. I cant assign a shortcut, i tried the following but it didnt worked(it compiles, but it does not assign the key)
//in the onconnection method:

SAFEARRAY arrSafe;
arrSafe.fFeatures =FADF_BSTR;
arrSafe.cbElements =35; //maby not necessary
arrSafe.cDims = 1; //maby not necessary

BSTR bstrShortCut =A2BSTR("Global::alt-s");
arrSafe.pvData = bstrShortCut;

VARIANT var1;
var1.vt = VT_ARRAY;
var1.parray = &arrSafe;

pCreatedCommand->put_Bindings(var1);

3. I would like to install my addins(the buttons) by default in a menu next to "Tools" which is called "MyAddins". how can i do this??? (i can manually make a new menu (Tools->customize,etc..) and then install my addin in there automatically (IfFailGoCheck(pCommandBars->get_Item(CComVariant(L"MyAddins"), &pMenuBarCommandBar), pMenuBarCommandBar);
but i cant make this "MyAddins" Menue automatically by code!!


THE FIRST DUDE, WHICH CAN HELP ME IN ANY OF THE 3 ISSUES (ISSUE 2. IS THE EASYEST, I GUESS)
WILL BE NOMINATED FOR THE OFFICAL "ADDIN-MASTER OF THE YEAR AWARD"

BernardSAS
April 3rd, 2003, 08:50 AM
hi

I am porting an add-in from Visual studio 6.0 to Visual Studio .NET, and I ran into the same troubles...

To use a custom icon in the menu

1) Create a DLL with a bitmap for the button icon - this is know as SatelliteDLL in MSDN documentation

2) Add the necesserary registration info in
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\AddIns\<your add-in name>.Connect"
SatelliteDLLName=<your DLL name>
SatelliteDLLPath=<the path to your DLL, terminating with \>

3) When creating the command, use the following syntax:
pCommands->AddNamedCommand (m_pAddInInstance,
strCmdName,
strCmdLabel,
strCmdHelp,
VARIANT_FALSE,
ID_BITMAP,
NULL,
EnvDTE::vsCommandStatusSupported + EnvDTE::vsCommandStatusEnabled,
&pCreatedCommand)

where ID_BITMAP is the ID in the satelliteDLL of the bitmap you want to use as icon for your button...

the VARIANT_FALSE value indicates that your command does not use a microsoft office icon, but a personnal icon.


I don't create a new menu, just a toolbar. I think that it's basically the same approach :

1) Retrieve the commands collection from IDE :

CComPtr<EnvDTE::Commands> pCommands;
HRESULT hr = m_pDTE->get_Commands (&pCommands);
if (hr != S_OK || pCommands == NULL)
return;


2) Create a new command bar

hr = pCommands->AddCommandBar (strTBLabel,
EnvDTE::vsCommandBarTypeToolbar,
NULL,
1,
(IDispatch**) &m_pCmdBar);
if (hr != S_OK || m_pCmdBar == NULL)
return;

3) Add controls to your command bar

CComPtr<Office::_CommandBarButton> pCtrl;
hr = pCreatedCommand->AddControl (m_pCmdBar, 1, (Office::CommandBarControl**) &pCtrl);
pCtrl->put_Style (Office::msoButtonIcon); // to use only icon in the toolbar

4) show your control bar

hr = m_pCmdBar->put_Visible (VARIANT_TRUE);


Well, now for shortcuts creation, i use basically the same technique and pCreatedCommand->put_Bindings returns E_INVALIDARG :mad:

andreas75
April 8th, 2003, 08:14 AM
ill check this out next week!

greetings!

endless2000
May 10th, 2003, 10:30 AM
:confused:
hello, I'm interested in this issue.by the way,
How to create a MenuItem in VC IDE programmatically?
Does anybody ever written an addin that create a menuitem in the VC IDE's main menu, like boundschecker does.
i write a program that need to integrate into the vc ide. i knew in some software u can do it by the vendor's develope kit. but in vc,
i didn't know how to do that?does vc provide these api?
i use the add-in wizard in dev studio to create the program