Visual Studio defines menus, groups and buttons by using a command table configuration (.ctc) file. This a is a text file with a pseudo C++ format that describes the command set for a VSPackage. A .ctc file is compiled into .cto by the ctc compiler (ctc.exe) and then embeded into a satellite assembly.
Here is how a CTC looks like:
NEWGROUPS_BEGIN
// NewGroup Parent Group Priority
guidPackageBrowserCommand:grpidPackageBrowserCommandGroup, guidPackageBrowserCommandParentGroup:grpidPackageBrowserCommandParentGroup, 0x0100;
NEWGROUPS_END
BUTTONS_BEGIN
// Command Parent Group Priority Image Type Visibility
guidPackageBrowserCommand:cmdidPackageBrowserCommand, guidPackageBrowserCommand:grpidPackageBrowserCommandGroup, 0x0100, guidPackageBrowserCommandBitmap:1, BUTTON, , "Package Browser";
BUTTONS_END
So we can say that the format is ugly, plus that we dont have intellisense, syntax coloring and other VS language features.
The succesor to the CTC is an xml-format based named VSCT. Because it is xml, it is easy to read and also we have the benefit of intellisense, syntax coloring and auto completion.
Here is how the VSCT looks like:
<
Buttons
>
<
Button
guid
="guidPackageBrowserCommand"id="cmdidPackageBrowserCommand"priority="0x100"type="Button">
<
Parent
guid
="guidPackageBrowserCommand"id="grpidPackageBrowserCommandGroup"/>
<
Icon
guid
="guidPackageBrowserCommandBitmap"id="1"/>
<
Strings
>
<
ButtonText
>Package Browser</ButtonText>
</
Strings
>
</
Button
>
</
Buttons
>
The VSCT is also compiled into a .cto file by the vsct compiler (vsct.exe) and then embeded into a satellite assembly.
Some pointers:
http://blogs.msdn.com/aaronmar/archive/2007/04/02/ctc-is-dead-long-live-vsct-part-1.aspx
http://blogs.msdn.com/aaronmar/archive/2007/05/11/ctc-is-dead-long-live-vsct-part-2.aspx
A walkthrough to convert a old fashioned CTC to a VSCT by Dmitri:
http://blog.neutron.sharpstyle.com/2007/05/09/adding-vsct-compilation-support-to-whidbey-vs-2005-projects/
Pablo
Before focusing on the creation of a VS Service with VSIPFactory, some little background:
- A VS Service is a contract between two VSPackages. One VSPackage offers a specific set of interfaces for another VSPackage to consume.
- A VS Service needs to be registered with VS, after we register it we can start consuming it
- Some useful pointers:
Now the steps to create a Service with VSIPFactory:
-
Enable VSIPFactory
- Right click on the VSPackage Project
- Choose VSIPFactory\Create\VS Service
- Specify the Service Name
- Provide the contract definition on the generated IService interface
- Provide the contract implementation on the generated service class
- Thats all :)
Pablo
VS SP1 introduced a really useful feature that will allow us to find any command GUID:ID pair.
To enable the feature we need to:
- Add the following registry information
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\General]
"EnableVSIPLogging"=dword:00000001
- Open a new instance of VS
Example usage:
Suppose that you want to find the GUID:ID pair of the File\Open menu item:
- Click on the File menu
- Hover the mouse over the Open sub menu
- Press CTRL + SHIFT
- Click on the Open menu
You could also use VSIPFactory to enable the feature for you:
Tip:
To get the content of the window you need to select the window and then press CTRL+C and paste it on a Notepad for example.
Pablo