Adding menus items (don't understand ProvideMenuResourceAttribute)
I'm taking the normal ToolWindow sample and modifying it to start a new package. This package simply exposes menu items and nothing else. I modified all of the commands and guids and names and stuff and now I'm not seeing my menus showing up as I expected them to. There is only one thing that I don't feel I've changed correctly (though this may not be the true problem) because I dont understand the numbers its using. At the top of the ToolWindow sample the attribute is added to the package class.
MSVSIP.ProvideMenuResource(1000, 1)
Now I believe I understand that this attribute is mostly there so the VSIPRegPkg utility can generate the correct registry entries. However I don't see where the number 1000 comes from. The docs indicate that this number should be the resourceID of the menu being added and this would seem to make sense. However in ToolWindowVB, the resourceID is &H100, not &H1000. Also considering the docs doesnt specify the number is a hex number, shouldnt this number be 256?
Anyway, if someone could explain this or point me to a doc that does I would appreciate it. If it matters, I changed my menu item IDs to be &H200, &H201 and &H202.
Also there are a couple things mentioned in the help that arent there. If they happen to be posted elsewhere I would love to read them. The docs say ....
"For the menu resource to merge correctly, the resource DLL must follow the satellite DLL conventions. It must be named <assemblyfile>UI.dll, and placed into an appropriate, localized subdirectory. For additional information on menus and menu resources, seeHow VSPackages Contribute User Interface Elements andMenu and Toolbar Commands."
Bill
What version of VS and the SDK are you using?
I see this doc entry in the June CTP build. So I suggest moving to a more recent build.
Searching in the help, ProvideMenuResource is meant to provide registration information on the menu resource itself, not on individual commands.
perhaps doc sections "How to:Create Basic Menus" and "Tool Window Registration and Configuration" will be of help as well.
Yes, I'm using the June CTP as well. However the page i found the reference on did not correctly link that document. I think it was on the ProvideMenuResourceAttribute help page.
So this is not needed for each menu item? OK. I still have no idea what that number is then, but i guess ill change it back to 1000 and keep poking things.
Thanks
Bill
Hi Bill,
The way VSPackage provides menus is by defining them in a .ctc file. That .ctc file is then complied to a .cto file using ctc.exe. That .cto is then merged with your resource. Usualy this is by including it in a .rc file to your satellite dll (UI dll). Note that in the new SDK that should be comming out shortly, we are making it possible to include the .cto directly in your managed assembly rather then using a separate unmanaged dll.
The ProvideMenuResourceAttribute is used to add registry entry (when running regpkg.exe or in everett VSIPRegPkg.exe). The 2 numbers that are part of the "Menus" registry entry are the resource ID of the .cto file and the version. The resource ID is used to find the .cto file since if we did not know what resource ID to use we would not know what resource to load from your package.
Before I explain what the version is used for, let me give you a bit more details on how VisualStudio makes use of the .cto file. When running devenv /setup, all the .cto (typically one per package, but a package can have none or many) are merged together to create the final menu layout. When VisualStudio starts, it check the version of each menu that is registered, and if that version is different from the version that was last merged, that .cto file will be merged again. That is if the version has changed, we assume the content changed and need to be merged again.
The toolbox items registration also use a version number in the same way.
Rusty