I have a Visual Studio add-in, which contains a scripting engine implemented in C++.
The add-in can only communicate with Visual Studio using IDispatch interfaces.
I am in the process of upgrading it from VS 2005 to VS 2010.
The add-in makes a series of IDispatch::Invoke() calls equivalent to this Visual Basic:
control = commandBar.Controls.Add(MsoControlType.msoControlButton)
control.Caption = "My button"
control.FaceId = 59
In VS 2005, this used to work. But in VS 2010 it doesn't. GetIDsOfNames() returns DISP_E_UNKNOWNNAME for "FaceId".
Note that "Caption" (which succeeds) is a property of CommandBarControl, and "FaceId" (which fails) is a property of the CommandBarButton subclass. The classname for the button's IDispatch* is CommandBarControl. So I think I need to downcast the CommandBarControl IDispatch* to a CommandBarButton IDispatch* somehow.
In Visual Basic I could write:
button = DirectCast(control, CommandBarButton)
button.FaceId = 59
But I don't know what DirectCast() does internally. If I did I'd probably be close to solving this.
Thanks