Menu Composition

Topics: CAB & Smart Client Software Factory
Oct 7, 2006 at 3:51 AM
originally posted by: bprobst

Hi all,
I just started with the CAB and run on minor shortcomings:

- The main menu including the Help entry is setup with the shell.
How can other workitems put their entries before the Help entry?
- How can I define a Default button (acting in <enter>) like in Windows.Form in the user controls

Oct 21, 2006 at 8:05 AM
originally posted by: kovlab49

Here's how I do it in my app: In ShellApp.AfterShellCreated, I pull the main menu-strip items and register them as UIExtensionSites on the root workitem ('_fileMenuItem' is how it's named in my MainForm instance; 'File' is the name I register it under in the CAB UIExtensionSites):

protected override void AfterShellCreated()
ToolStripMenuItem fileItem = (ToolStripMenuItem)Shell.MainMenuStrip.Items"_fileMenuItem";
RootWorkItem.UIExtensionSites.RegisterSite("File", fileItem.DropDownItems);
ToolStripMenuItem helpItem = (ToolStripMenuItem)Shell.MainMenuStrip.Items"_helpMenuItem";
RootWorkItem.UIExtensionSites.RegisterSite("Help", helpItem.DropDownItems);

.... so in my other modules, I can create the ToolStripMenuItem I want to add, then add it thus:

workItem.Commandsmapping.ActionName.AddInvoker(menuItem, "Click");

Where you get the RootWorkItem from depends upon exactly where you're doing this.