One question, though.
I'm having difficulty obtaining a reference to the CommandBarButton =
(menu item) object that will execute my command. How would I go about =
this, given the code previously provided?
"Carlos J. Quintero [.NET MVP]" <carlosq@NOSPAMsogecable.com> wrote in =
message news:u8tg8iHBFHA.2104@TK2MSFTNGP14.phx.gbl...
1) The neededText parameter is always vsCommandStatusTextWantedNone in =
VS.NET 2002/2003, but your add-in should always verify that this is the =
value passed because the other values are reserved for future versions =
of Visual Studio .NET (source: book "Inside Microsoft Visual Studio .NET =
2003", Microsoft Press, by Craig Skibo and others).
2) This means that to change the Name / ButtonText properties of a =
command you must re-create it (since they set when the command is =
created, not as writable properties). However, you can change =
dynamically the CommandBarButton.Caption of the controls created from =
that command. Maybe this is enough for you.
3) Ninched is the opposite of Latched, for commands that display an =
On/Off state (pressed/unpressed) rather than performing an action as =
usual. My add-in (below) uses one of those commands to =
activate/deactivate its "Intelligent Design Mode" feature.
I think that I did all you want in my add-in. If you have problems =
with it, let me know and I will take a closer look at the code.
--=20
Carlos J. Quintero=20
MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET=20
You can code, design and document much faster.
http://www.mztools.com "WALDO" <NOSPAM@NOSPAM.COM> escribi=F3 en el mensaje =
news:OdOVM0$AFHA.3016@tk2msftngp13.phx.gbl...
I am developing an addin to compile vb projects using the command =
line and win32 resources. I have created commands and menu items for =
those commands. What I want to know is how do I create my command so =
that QueryStatus may be called with something other than None. I want it =
to be TextWanted so that I may change the text on my menu item =
dynamically based on the active selection. This will work similar to the =
built-in Build <ProjectName> and Rebuild <ProjectName> menu items under =
the Build menu. All I ever get is None.
A condensed exerpt of my code is as follows:
Public Sub OnConnection(ByVal application As Object, ByVal connectMode =
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef =
custom As System.Array) Implements =
Extensibility.IDTExtensibility2.OnConnection applicationObject =3D =
CType(application, EnvDTE.DTE) addInInstance =3D CType(addInInst, =
EnvDTE.AddIn) If connectMode =3D =
Extensibility.ext_ConnectMode.ext_cm_UISetup Then Dim objAddIn As =
AddIn =3D CType(addInInst, AddIn) Dim CommandObj As Command =
Try CommandObj =3D =
applicationObject.Commands.AddNamedCommand(objAddIn, "MyAddin2", =
"MyAddin2", "Executes the command for MyAddin2", True, 59, Nothing, 1 + =
2) '1+2 =3D=3D vsCommandStatusSupported+vsCommandStatusEnabled =
CommandObj.AddControl(applicationObject.CommandBars.Item("Tools")) =
Catch e as System.Exception End Try End IfEnd Sub Public Sub =
QueryStatus(ByVal cmdName As String, ByVal neededText As =
vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef =
commandText As Object) Implements IDTCommandTarget.QueryStatus '... =
If neededText =3D vsCommandStatusTextWanted.vsCommandStatusTextWanted =
Then commandText =3D "Dynamically Change the text on my menu =
item." End IfEnd Sub Any help would be greatly appreciated.Thanks in =