Sometimes is necessary to change the text for a menu item depending on the selection. In order to do that you have to do 2 things:
1) If it is a command defined in your package you have to set the flag TEXTCHANGES in the ctc file. For example
guidProjectCmdSet:mycmdCompile , guidProjectCmdSet:MyMenuGroup, 0x0100, guidProjectCmdSet:bmpPic1, BUTTON, TEXTCHANGES , "&Compile";
2) You have to return the text in the querystatus method of your IOleCommandTarget implementation
Then you should do something like this:
....
case mycmdCompile:
{
string s = "Hello, I have changed this text";
OLECMDTEXT cmdText = (OLECMDTEXT) Marshal.PtrToStructure(pCmdText, typeof(OLECMDTEXT));
if (cmdText.cmdtextf == 1 /* OLECMDTEXTF_NAME */ )
{
NativeMethods.OLECMDTEXT.SetText(pCmdText, s);
}
....
}
This is a sample of using Automation on a VSIPExtras package.
If you don't know how many things you can do with automation I recommend you read this book http://www.microsoft.com/mspress/books/6425.asp
I don't want wait for Whidbey in order to use a couple of useful commands in the IDE, then I implemented them for VS2003.
Documentation (Full documentation will be available on Whidbey documentation :)
- Close All but this ( Close all document windows but this)
- Copy Full Path ( Copy the full path of the active document to the clipboard )
- Show File In Explorer ( Show File in Explorer :)
Installation:
Download (Code included) Check this post Open visual studio command prompt and run "devenv /setup"