all groups > visual studio .net ide > january 2005 >
You're in the

visual studio .net ide

group:

vsCommandStatusTextWanted, when does it change?


vsCommandStatusTextWanted, when does it change? WALDO
1/26/2005 6:16:19 PM
visual studio .net ide:
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 SubPublic 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 SubAny help would be greatly appreciated.Thanks in =
Re: vsCommandStatusTextWanted, when does it change? WALDO
1/26/2005 8:01:11 PM
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 = CType(application, EnvDTE.DTE) addInInstance =
CType(addInInst, EnvDTE.AddIn)
If connectMode = Extensibility.ext_ConnectMode.ext_cm_UISetup Then
Dim objAddIn As AddIn = CType(addInInst, AddIn)
Dim CommandObj As Command
Try
CommandObj =
applicationObject.Commands.AddNamedCommand(objAddIn, "MyAddin2", "MyAddin2",
"Executes the command for MyAddin2", True, 59, Nothing, 1 + 2) '1+2 ==
vsCommandStatusSupported+vsCommandStatusEnabled

CommandObj.AddControl(applicationObject.CommandBars.Item("Tools"))
Catch e as System.Exception
End Try
End If
End 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 = vsCommandStatusTextWanted.vsCommandStatusTextWanted Then
commandText = "Dynamically Change the text on my menu item."
End If
End Sub


Any help would be greatly appreciated.

Thanks in advance.
BTW - What is ninched?

Re: vsCommandStatusTextWanted, when does it change? WALDO
1/27/2005 9:30:24 AM
Thanks, Carlos.
You've been very helpful.
"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 =
Re: vsCommandStatusTextWanted, when does it change? WALDO
1/27/2005 9:56:13 AM
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 =
Re: vsCommandStatusTextWanted, when does it change? WALDO
1/27/2005 10:01:49 AM
Nevermind. Figured it out. d'uh
"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 =
Re: vsCommandStatusTextWanted, when does it change? WALDO
1/27/2005 10:24:32 AM
OK. One last thing. In my Query status, I change my Caption when I need =
to, but the width of the caption is bigger than the existing menu items. =
The menu that it is attached to does not compensate for the width and =
therefore cuts off my caption. What can I do about that?
"Carlos J. Quintero [.NET MVP]" <carlosq@NOSPAMsogecable.com> wrote in =
message news:%23zlg1FIBFHA.2792@TK2MSFTNGP15.phx.gbl...
Command.AddControl() or CommandBar.Controls.Item(n) returns a =
CommandBarControl that you must cast to CommandBarButton.=20

--=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:%23lvbZBIBFHA.3236@TK2MSFTNGP15.phx.gbl...
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 =
Re: vsCommandStatusTextWanted, when does it change? WALDO
1/27/2005 12:30:51 PM
It seems that QueryStatus is too late to change the caption. When you =
pull down the menu, it is already sized to its contents before =
QueryStatus is called. If I change it then, It won't make a diffrence =
the first time I pull down that menu. The next time, when the menu is =
sized, then QueryStatus is called, and I don't have to change my =
caption, it will be sized properly.

What I ended up doing was handling the Selection OnChange event and =
refreshing my menu items then. (which is really what I was going for, so =
that worked out.

"Carlos J. Quintero [.NET MVP]" <carlosq@NOSPAMsogecable.com> wrote in =
message news:eoCMyRJBFHA.2428@TK2MSFTNGP14.phx.gbl...
Ummm, I think that the menu should recalculate its width but if not, =
you could add enough spaces to the original shorter caption, maybe it =
does the trick...

--=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:O7XVORIBFHA.2788@TK2MSFTNGP15.phx.gbl...
OK. One last thing. In my Query status, I change my Caption when I =
need to, but the width of the caption is bigger than the existing menu =
items. The menu that it is attached to does not compensate for the width =
Re: vsCommandStatusTextWanted, when does it change? Carlos J. Quintero [.NET MVP]
1/27/2005 3:01:42 PM
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 =
Re: vsCommandStatusTextWanted, when does it change? Carlos J. Quintero [.NET MVP]
1/27/2005 4:04:08 PM
Command.AddControl() or CommandBar.Controls.Item(n) returns a =
CommandBarControl that you must cast to CommandBarButton.=20

--=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:%23lvbZBIBFHA.3236@TK2MSFTNGP15.phx.gbl...
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 =
Re: vsCommandStatusTextWanted, when does it change? Carlos J. Quintero [.NET MVP]
1/27/2005 6:20:03 PM
Ummm, I think that the menu should recalculate its width but if not, you =
could add enough spaces to the original shorter caption, maybe it does =
the trick...

--=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:O7XVORIBFHA.2788@TK2MSFTNGP15.phx.gbl...
OK. One last thing. In my Query status, I change my Caption when I =
need to, but the width of the caption is bigger than the existing menu =
items. The menu that it is attached to does not compensate for the width =
AddThis Social Bookmark Button