Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, Is it possible to create either a new submenu off the Tools menu, or a completely new menu on the main menu bar, and then place my commands in a possibly nested structure inside of this menu? The .ctc file is somewhat cryptic, and thus far I've only been able to put my commands on other existing menus, one level deep. Thanks. -Parag Chandra
Post Follow-up to this messageHi Parag, The newer VSIP docs (VSIP 8.0 Beta2) have some good guidelines for managing your .CTC file. It's defintely not easy to learn. Below is the .CTC file from a sample I'm working on. I tend to prefer using the CMDPLACEMENT_SECTION to define what commands are in what groups and such. This same technique is used by most of the MS packages. It's easiest to construct your menus in the following order. First add your commands to the BUTTONS_BEGIN section, with a Guid:NULL parent group. Then define your groups in the NEWGROUPS_BEGIN section. I like to group related commands, so I actually have two groups in the sample below. This allows for reusing a group of commands elsewhere. Additionally, I also defined a group for my cascade menu. Then it's just a matter of locating the commands in the proper groups, and associating the groups to the desired menus. Hopefully, this will get you pointed in the right direction. #include "stdidcmd.h" #include "vsshlids.h" #include "msobtnid.h" #include "virtkeys.h" #include "PkgCmdID.h" #include "Resource.h" #define _CTC_GUIDS_ #include "Guids.h" // shorthand macros for a more compact and manageable table #define OI_NOID guidOfficeIcon:msotcidNoIcon #define DIS_DEF DEFAULTDISABLED | DEFAULTINVISIBLE | DYNAMICVISIBILITY #define VIS_DEF COMMANDWELLONLY CMDS_SECTION guidMagicMarkersPkg MENUS_BEGIN // NewMenu, Relative to Group, Priority, Type, Name, Text; guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, 0x0000, , "&Magic Markers"; MENUS_END NEWGROUPS_BEGIN // NewGroup, Parent Group, Priority; guidMagicMarkersPkg:IDG_CASCADE, guidMagicMarkersPkg:IDG_CASCADE, 0x0000; guidMagicMarkersPkg:IDG_MARKERCOMMANDS, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0000; NEWGROUPS_END BUTTONS_BEGIN // Command, Parent Group, Priority, Image, Type, Visibility; guidMagicMarkersCmdSet:cmdidInsertNoisyG lyphMarker, guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Noisy Glyph Marker"; guidMagicMarkersCmdSet:cmdidInsertSelMar ginMarker, guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Selection Margin Marker"; guidMagicMarkersCmdSet:cmdidInsertLineMa rker, guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Line Marker"; guidMagicMarkersCmdSet:cmdidInsertBorder Marker, guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Border Marker"; guidMagicMarkersCmdSet:cmdidInsertDragga bleMarker, guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Draggable Marker"; BUTTONS_END BITMAPS_BEGIN // Bitmap, Bitmap Index, Bitmap Index, ... guidMagicMarkersCmdSet:IDB_MENU_IMAGES, bmpPic1, bmpPic2, bmpPicSmile, bmpPicX, bmpPicArrows; BITMAPS_END CMDS_END CMDUSED_SECTION CMDUSED_END CMDPLACEMENT_SECTION // Command, Group, Priority; // locate commands in IDG_MARKERCOMMANDS group guidMagicMarkersCmdSet:cmdidInsertNoisyG lyphMarker, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0100; guidMagicMarkersCmdSet:cmdidInsertSelMar ginMarker, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0101; guidMagicMarkersCmdSet:cmdidInsertLineMa rker, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0102; guidMagicMarkersCmdSet:cmdidInsertBorder Marker, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0103; guidMagicMarkersCmdSet:cmdidInsertDragga bleMarker, guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0104; // add IDG_MARKERGROUP to IDM_MAGICMARKERS_CASCADE menu guidMagicMarkersPkg:IDG_MARKERCOMMANDS, guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, 0x0100; // locate cascade menu in the cascade group guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, guidMagicMarkersPkg:IDG_CASCADE, 0x0100; // place cascade group in code window context menu guidMagicMarkersPkg:IDG_CASCADE, guidSHLMainMenu:IDM_VS_CTXT_CODEWIN, 0x0300; CMDPLACEMENT_END VISIBILITY_SECTION // Command, GUID when visible; VISIBILITY_END KEYBINDINGS_SECTION // Command, when available, emulation, keystate; KEYBINDINGS_END Sincerely, Ed Dore [MSFT] This post is 'AS IS' with no warranties, and confers no rights.
Post Follow-up to this messageOk, I think I'm getting closer. I've restructured my CTC file to match yours, so now it's easier to relocate an entire group of commands just by changing the line for the group under CMDPLACEMENT_SECTION. However, I still can't get them to appear as a submenu. I've tried creating an actual menu resource (IDR_MENU1) using the resource editor and using that as the parent of my group, then parenting that menu under Visual Studio's Tools menu, but nothing appears there when I do that. I also just tried defining an arbitrary menu 'MyMenu' with ID 0x1019 in the PkgCmdID.h file, and using that in place of IDR_MENU1, but that doesn't yield anything either. I've pasted the contents of my CTC file below. Thanks for your help. CMDS_SECTION guidVsPackage1Pkg MENUS_BEGIN // NewMenu Relative to Group Priority Type Name Text guidVsPackage1Pkg:IDR_MENU1, guidVsPackage1Pkg:IDR_MENU1, 0x0000, , "SlickEdit"; MENUS_END NEWGROUPS_BEGIN // NewGroup Parent Group Priority guidVsPackage1Pkg:MyMenuGroup, guidVsPackage1Pkg:MyMenuGroup, 0x0000; NEWGROUPS_END BUTTONS_BEGIN // Command Parent Group Priority Image Type Visibility guidVsPackage1CmdSet:cmdidMyCommand, guidVsPackage1CmdSet:0, 0x0100, guidVsPackage1CmdSet:bmpPic1, BUTTON, , "VsPackage1 Command"; guidVsPackage1CmdSet:cmdidMyTool, guidVsPackage1CmdSet:0, 0x0100, guidVsPackage1CmdSet:bmpPic2, BUTTON, , "VsPackage1 ToolWindow"; BUTTONS_END BITMAPS_BEGIN // Bitmap Bitmap Index, Bitmap Index, ... guidVsPackage1CmdSet:IDB_MENU_IMAGES, bmpPic1, bmpPic2, bmpPicSmile, bmpPicX, bmpPicArrows; BITMAPS_END CMDS_END CMDUSED_SECTION CMDUSED_END CMDPLACEMENT_SECTION // Command Group Priority guidVsPackage1CmdSet:cmdidMyCommand, guidVsPackage1Pkg:MyMenuGroup, 0x0100; guidVsPackage1CmdSet:cmdidMyTool, guidVsPackage1Pkg:MyMenuGroup, 0x0101; guidVsPackage1Pkg:MyMenuGroup, guidSHLMainMenu:IDR_MENU1, 0x0000; guidVsPackage1Pkg:IDR_MENU1, guidSHLMainMenu:IDM_VS_MENU_TOOLS, 0x0600; CMDPLACEMENT_END VISIBILITY_SECTION // Command GUID when visible VISIBILITY_END ""Ed Dore [MSFT]"" <eddo@online.microsoft.com> wrote in message news:18iftbITFHA.2476@TK2MSFTNGXA01.phx.gbl... > Hi Parag, > > The newer VSIP docs (VSIP 8.0 Beta2) have some good guidelines for > managing > your .CTC file. It's defintely not easy to learn. Below is the .CTC file > from a sample I'm working on. I tend to prefer using the > CMDPLACEMENT_SECTION to define what commands are in what groups and such. > This same technique is used by most of the MS packages. > > It's easiest to construct your menus in the following order. > > First add your commands to the BUTTONS_BEGIN section, with a Guid:NULL > parent group. Then define your groups in the NEWGROUPS_BEGIN section. I > like to group related commands, so I actually have two groups in the > sample > below. This allows for reusing a group of commands elsewhere. > Additionally, I also defined a group for my cascade menu. Then it's just a > matter of locating the commands in the proper groups, and associating the > groups to the desired menus. > > Hopefully, this will get you pointed in the right direction. > > #include "stdidcmd.h" > #include "vsshlids.h" > #include "msobtnid.h" > #include "virtkeys.h" > #include "PkgCmdID.h" > #include "Resource.h" > > #define _CTC_GUIDS_ > #include "Guids.h" > > // shorthand macros for a more compact and manageable table > > #define OI_NOID guidOfficeIcon:msotcidNoIcon > #define DIS_DEF DEFAULTDISABLED | DEFAULTINVISIBLE | > DYNAMICVISIBILITY > #define VIS_DEF COMMANDWELLONLY > > CMDS_SECTION guidMagicMarkersPkg > > MENUS_BEGIN > // NewMenu, Relative to Group, Priority, Type, Name, Text; > guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, > guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, 0x0000, , "&Magic Markers"; > MENUS_END > > NEWGROUPS_BEGIN > // NewGroup, Parent Group, Priority; > guidMagicMarkersPkg:IDG_CASCADE, guidMagicMarkersPkg:IDG_CASCADE, > 0x0000; > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0000; > NEWGROUPS_END > > BUTTONS_BEGIN > // Command, Parent Group, Priority, Image, Type, Visibility; > guidMagicMarkersCmdSet:cmdidInsertNoisyG lyphMarker, > guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Noisy Glyph > Marker"; > guidMagicMarkersCmdSet:cmdidInsertSelMar ginMarker, > guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Selection Margin > Marker"; > guidMagicMarkersCmdSet:cmdidInsertLineMa rker, > guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Line Marker"; > guidMagicMarkersCmdSet:cmdidInsertBorder Marker, > guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Border Marker"; > guidMagicMarkersCmdSet:cmdidInsertDragga bleMarker, > guidMagicMarkersCmdSet:0, 0x0000, OI_NOID, BUTTON, , "&Draggable Marker"; > BUTTONS_END > > BITMAPS_BEGIN > // Bitmap, Bitmap Index, Bitmap Index, ... > guidMagicMarkersCmdSet:IDB_MENU_IMAGES, bmpPic1, bmpPic2, > bmpPicSmile, bmpPicX, bmpPicArrows; > BITMAPS_END > > CMDS_END > > CMDUSED_SECTION > CMDUSED_END > > CMDPLACEMENT_SECTION > // Command, Group, Priority; > > // locate commands in IDG_MARKERCOMMANDS group > guidMagicMarkersCmdSet:cmdidInsertNoisyG lyphMarker, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0100; > guidMagicMarkersCmdSet:cmdidInsertSelMar ginMarker, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0101; > guidMagicMarkersCmdSet:cmdidInsertLineMa rker, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0102; > guidMagicMarkersCmdSet:cmdidInsertBorder Marker, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0103; > guidMagicMarkersCmdSet:cmdidInsertDragga bleMarker, > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, 0x0104; > > // add IDG_MARKERGROUP to IDM_MAGICMARKERS_CASCADE menu > guidMagicMarkersPkg:IDG_MARKERCOMMANDS, > guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, 0x0100; > > // locate cascade menu in the cascade group > guidMagicMarkersPkg:IDM_MAGICMARKERS_CAS CADE, > guidMagicMarkersPkg:IDG_CASCADE, 0x0100; > > // place cascade group in code window context menu > guidMagicMarkersPkg:IDG_CASCADE, guidSHLMainMenu:IDM_VS_CTXT_CODEWIN, > 0x0300; > > CMDPLACEMENT_END > > VISIBILITY_SECTION > // Command, GUID when visible; > VISIBILITY_END > > KEYBINDINGS_SECTION > // Command, when available, emulation, keystate; > KEYBINDINGS_END > > Sincerely, > Ed Dore [MSFT] > > This post is 'AS IS' with no warranties, and confers no rights. >
Post Follow-up to this messageI think I've got it. I followed the CTC file for the DynamicMenu C# sample and now I have a cascaded menu, just like I wanted. Thanks for your help. -Parag "Parag Chandra" <slickedit@newsgroup.nospam> wrote in message news:%23DmzzKNTFHA.3152@TK2MSFTNGP12.phx.gbl... > Ok, I think I'm getting closer. I've restructured my CTC file to match > yours, so now it's easier to relocate an entire group of commands just by > changing the line for the group under CMDPLACEMENT_SECTION. However, I > still can't get them to appear as a submenu. I've tried creating an actual > menu resource (IDR_MENU1) using the resource editor and using that as the > parent of my group, then parenting that menu under Visual Studio's Tools > menu, but nothing appears there when I do that. I also just tried defining > an arbitrary menu 'MyMenu' with ID 0x1019 in the PkgCmdID.h file, and > using that in place of IDR_MENU1, but that doesn't yield anything either. > I've pasted the contents of my CTC file below. Thanks for your help. > > CMDS_SECTION guidVsPackage1Pkg > > MENUS_BEGIN > // NewMenu Relative to Group Priority > Type Name Text > guidVsPackage1Pkg:IDR_MENU1, guidVsPackage1Pkg:IDR_MENU1, 0x0000, , > "SlickEdit"; > MENUS_END > > NEWGROUPS_BEGIN > // NewGroup Parent Group Priority > guidVsPackage1Pkg:MyMenuGroup, guidVsPackage1Pkg:MyMenuGroup, 0x0000; > NEWGROUPS_END > > BUTTONS_BEGIN > // Command Parent Group Priority > Image Type Visibility > guidVsPackage1CmdSet:cmdidMyCommand, guidVsPackage1CmdSet:0, 0x0100, > guidVsPackage1CmdSet:bmpPic1, BUTTON, , "VsPackage1 Command"; > guidVsPackage1CmdSet:cmdidMyTool, guidVsPackage1CmdSet:0, 0x0100, > guidVsPackage1CmdSet:bmpPic2, BUTTON, , "VsPackage1 > ToolWindow"; > > BUTTONS_END > > BITMAPS_BEGIN > // Bitmap Bitmap Index, Bitmap Index, ... > guidVsPackage1CmdSet:IDB_MENU_IMAGES, bmpPic1, bmpPic2, bmpPicSmile, > bmpPicX, bmpPicArrows; > BITMAPS_END > > CMDS_END > > CMDUSED_SECTION > CMDUSED_END > > CMDPLACEMENT_SECTION > // Command Group Priority > guidVsPackage1CmdSet:cmdidMyCommand, guidVsPackage1Pkg:MyMenuGroup, > 0x0100; > guidVsPackage1CmdSet:cmdidMyTool, guidVsPackage1Pkg:MyMenuGroup, > 0x0101; > > guidVsPackage1Pkg:MyMenuGroup, guidSHLMainMenu:IDR_MENU1, 0x0000; > > guidVsPackage1Pkg:IDR_MENU1, guidSHLMainMenu:IDM_VS_MENU_TOOLS, 0x0600; > CMDPLACEMENT_END > > VISIBILITY_SECTION > // Command GUID when visible > VISIBILITY_END > > > > ""Ed Dore [MSFT]"" <eddo@online.microsoft.com> wrote in message > news:18iftbITFHA.2476@TK2MSFTNGXA01.phx.gbl... > >
Post Follow-up to this messageThanks for the follow up Parag, I haven't had an opportunity to dig into that particular sample yet. I'm looking into that new Options Page C# package sample, with respect to that options page nesting issue. I'll post a response in just a bit, on that thread. Sincerely, Ed Dore [MSFT] This post is 'AS IS' with no warranties and confers no rights.
Post Follow-up to this messageOk, I thought I had this one figured out, but I still have a lot of questions. Here's my scenario: I want to implement several different features, and I would like each one to be completely self-contained inside its own package. In addition to placing the commands for each feature on appropriate context menus, I would also like them to be available on one master menu as well. This master menu might be rooted on Visual Studio's Tools menu (IDM_VS_MENU_TOOLS) or on the main menu itself (IDM_VS_TOOL_MAINMENU). Given this scenario, how can I ensure that only one instance of this master menu is present in Visual Studio, no matter how many of my packages are registered? Right now I include a common header file in each of my package's CTC files, and then each of these CTC files contains appropriate lines in the MENUS and NEWGROUPS sections to create this menu, like this: MENUS_BEGIN guidMainMenu:IDM_SE_MAIN, guidMainMenu:IDG_SE_MAIN, 0x0000, , "MainMenu", "MainMenu"; MENUS_END NEWGROUPS_BEGIN guidMainMenu:IDG_SE_MAIN, guidSHLMainMenu:IDM_VS_TOOL_MAINMENU, 0x0600; guidThisPackage:IDG_SE_PACKAGE, guidThisPackage:IDG_SE_PACKAGE, 0x0010; NEWGROUPS_END BUTTONS_BEGIN guidThisPackageCmdSet:cmdidMyCommand1, guidThisPackageCmdSet:0, 0x0100, ... guidThisPackageCmdSet:cmdidMyCommand2, guidThisPackageCmdSet:0, 0x0100, ... BUTTONS_END CMDPLACEMENT_SECTION guidThisPackageCmdSet:cmdidMyCommand1, guidThisPackageCmdSet:IDG_SE_PACKAGE, 0x0100; guidThisPackageCmdSet:cmdidMyCommand2, guidThisPackageCmdSet:IDG_SE_PACKAGE, 0x0101; guidThisPackageCmdSet:IDG_SE_PACKAGE, guidMainMenu:IDM_SE_MAIN, 0x0010; CMDPLACEMENT_END If only one of my packages registers, then all of its commands are displayed correctly in this main menu. If I register the second package as well, then I get four copies of this MainMenu, and each of them has the commands for both packages. I thought that using the same GUID:ID pair would ensure that the menu is unique, but that's not the case. I tried various combinations of commenting out the ProvideMenuResourceAttribute, MENUS_BEGIN and NEWGROUPS_BEGIN lines, but no luck. Do I need to create some tiny auxiliary package whose purpose is simply to create this master menu? "Parag Chandra" <slickedit@newsgroup.nospam> wrote in message news:O2KiOJOTFHA.2828@TK2MSFTNGP10.phx.gbl... >I think I've got it. I followed the CTC file for the DynamicMenu C# sample >and now I have a cascaded menu, just like I wanted. Thanks for your help. > > -Parag > > "Parag Chandra" <slickedit@newsgroup.nospam> wrote in message > news:%23DmzzKNTFHA.3152@TK2MSFTNGP12.phx.gbl... > >
Post Follow-up to this messageHi Parag, As Ed mentioned, he will reply in that new Options Page C# pakage thread. If you have any more concerns, could you please post there so that we can follow up in the same thread? Thanks very much. Best regards, Yanhong Huang Microsoft Community Support Get Secure! ¨C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! -http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as p&SD=msdn This posting is provided "AS IS" with no warranties, and confers no rights.
Post Follow-up to this messageHi Parag, Not sure I have a good answer for this, given I don't know what kind of functionality you have planned for each package. Have you considered implementing said menus/commands in a base (common) package? I'm not sure what these individual packages do, but you could potentially tie these common menus/commands to a specific CommandUIGuid. So that they only appear when a document window has focus, or a particular hierarchy item is selected. The VSIP documentation (2003 version) has a few topics such as "Reuse Shared Commands" and "Showing Commands According to Current Context" that may give you some ideas. Note, packages that make use of shared commands (commands implemented/defined in a different package) should ensure that the commands are listed in the CMD_USED section of thier respective .CTC files. I've run into some problems in the past where package vendors didn't do this, and as a result, the commands were not available. Sincerely, Ed Dore [MSFT] This post is 'AS IS' with no warranties, and confers no rights.
Post Follow-up to this messageSo the scenario I described is possible if I place all the commands on an _existing_ Visual Studio menu (like directly on the 'Tools' menu), but it's not possible if I want them to appear on a menu that I create myself (like a submenu hanging off the 'Tools' menu) ? ""Ed Dore [MSFT]"" <eddo@online.microsoft.com> wrote in message news:cGi78EAUFHA.3928@TK2MSFTNGXA01.phx.gbl... > Hi Parag, > > Not sure I have a good answer for this, given I don't know what kind of > functionality you have planned for each package. Have you considered > implementing said menus/commands in a base (common) package? > > I'm not sure what these individual packages do, but you could potentially > tie these common menus/commands to a specific CommandUIGuid. So that they > only appear when a document window has focus, or a particular hierarchy > item is selected. > > The VSIP documentation (2003 version) has a few topics such as "Reuse > Shared Commands" and "Showing Commands According to Current Context" that > may give you some ideas. Note, packages that make use of shared commands > (commands implemented/defined in a different package) should ensure that > the commands are listed in the CMD_USED section of thier respective .CTC > files. I've run into some problems in the past where package vendors > didn't > do this, and as a result, the commands were not available. > > Sincerely, > Ed Dore [MSFT] > > This post is 'AS IS' with no warranties, and confers no rights. >
Post Follow-up to this messageHi Parag, Placing the commands on an existing VS menu shouldn't be a requirement. Your master menu needs to be implemented by a common "base package" that's always installed and registered. Additionally ,this common package should also implement any shared commands. These commands can be hidden by default, and enabled/displayed by your other packages. Subsquent packages can define their own menu groups (consisting of package specific and/or shared commands), and then place these groups in the desired context menus. Let me know if this doesn't make sense. Sincerely, Ed Dore [MSFT] This post is 'AS IS' with no warranties, and confers no rights.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.