Problem with AddNamedCommand and tooltips

Hi.

I'm using AddNamedCommand to create a custom command in my add-in:

pCommands->AddNamedCommand(m_pAddInInstance, CComBSTR("Settings"), CComBSTR("Settings"), CComBSTR("Edit add-in settings"), VARIANT_TRUE, 3049, NULL, EnvDTE::vsCommandStatusSupported+EnvDTE::vsCommandStatusEnabled, &pSettings);

In Visual Studio 2003 the tooltip for the command is "Edit add-in settings" as I expect.

In Visual Studio 2005 the tooltip is "Settings". Seems like it is using the button name as a tooltip. Is there a way to have different button name and tooltip?

Thanks

Ivo

[666 byte] By [Ivo] at [2007-12-25]
# 1
Anybody?
Ivo at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 2

It seems a bug to me. You can report it here:

http://connect.microsoft.com/feedback/default.aspx?SiteID=210

As a workaround, you can cast the result of the call Command.AddControl(...) to CommandBarButton and change the TooltipText property.

CarlosQuinteroMVP at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 3
Do I need QueryInterface, or just a plain cast?
Ivo at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 4
Just a plain cast. The result is returned as CommandBarControl but you have to cast it to CommandBarButton to get access to the TooltipText property.
CarlosQuinteroMVP at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 5

I got it to work. For those interested, here's the exact code:

CComPtr<Microsoft_VisualStudio_CommandBars::_CommandBarButton> control;

pSettings->AddControl(bar,1,(IDispatch**)&control);
control->put_TooltipText(CComBSTR("Edit add-in settings"));
control->put_Style(Microsoft_VisualStudio_CommandBars::msoButtonIcon);

Note the _ infront of CommandBarButton.

Ivo

Ivo at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified