Menu Composition

Topics: CAB & Smart Client Software Factory
Oct 7, 2006 at 2: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

TIA BP
Oct 21, 2006 at 7: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()
{
base.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.UIExtensionSitesmapping.Site.Add(menuItem);
workItem.Commandsmapping.ActionName.AddInvoker(menuItem, "Click");

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