CAB and MDI Workspace

Topics: CAB & Smart Client Software Factory
Dec 8, 2006 at 6:48 AM
originally posted by: souyang


We are currently developing a relatively large application and are planning to use CAB, and I must say the learn curve is quite steep. I have a few requirements that I’m not quite sure how to go about implementing them with CAB, and I’m hoping that you guys can help.

Let me give you some background first of all.
Our application is an MDI application and so we are using MDI Workspace. Upon loading of a module, each module will load as normal (registering UI extension sites) with the exception that no workspaces and views are loaded. The commands associated with the menu items will however invoke procedures in the Module Controller to construct the necessary workitems, workspaces, and views and show them. This will also allow us to create multiple instances of the same MDI child.

1. I just want to validate our approach here. Does this seem like a proper usage of the Module Control in the application?
2. For the menu strip, one of the requirements is to have a Window menu item like most MDI application does. Every time I load an MDI child, I need to add a sub menu item to the Window menu item. Like most MDI application, the intention is to allow users to navigate to any of their forms (MDI child) at any given point. I’m thinking about using Even Pub/Sub to update the menu strip in the shell, but it would seem like every sub menu item under the Window menu item will have the same command handler. How do I associate an MDI child to a specific menu item and upon click, put focus on the proper MDI child?

Thanks in advance.
Dec 8, 2006 at 10:50 PM
originally posted by: akol_dk

We are currently developing an MDI application. We are using Smart Client Software Factory (SCSF). Have you looked at that?

1) We are following the same approch as you have suggested, and it works just fine. However. so far we are only showing one instance of each view, so I can't tell if there is going to be a problem showing more instances of each view. Probably not.

The only issue we have run into is with closing MDI views. We have found that the implementation in CAB/SCSF is not good enough, so we have had to implement extra functionality to handle closing and reopening of views, especially if you want to be able to respond to and perhaps cancel a close event.

I would suggest that you implement a common view base class and let all your views inherit from this. You might want to change some of the SCSF recipies so that the view created by the Add View recipie automatically uses your common view. I think there is some help on this in the SCSF forum. Try to do a search.

2) Actually the Windows menu is not that difficult to implement. Most of the functionality is already there. We have created a separate module to the Windows menu item, and implemented the following in the ModuleControler:

private void ExtendMenu()
ToolStripMenuItem windowMenuItem = new ToolStripMenuItem("&Vindue");
AddMenuItem(windowMenuItem, "&Horisontalt", CommandNames.HorizontalWindowCommandName, 0);
AddMenuItem(windowMenuItem, "&Vertikalt", CommandNames.VerticalWindowCommandName, 0);
AddMenuItem(windowMenuItem, "&Kaskade", CommandNames.CascadeWindowCommandName, 0);

//generate list of open views under windowsMenuItem
MenuStrip menu = (MenuStrip)windowMenuItem.Owner;
menu.MdiWindowListItem = windowMenuItem;

public void VerticalWindow(Object sender, EventArgs e)
MdiWorkspace mws = (MdiWorkspace)WorkItem.WorkspacesWorkspaceNames.MDIWorkspace;

public void HorizontalWindow(Object sender, EventArgs e)
MdiWorkspace mws = (MdiWorkspace)WorkItem.WorkspacesWorkspaceNames.MDIWorkspace;

public void CascadeWindow(Object sender, EventArgs e)
MdiWorkspace mws = (MdiWorkspace)WorkItem.WorkspacesWorkspaceNames.MDIWorkspace;

I hope this helps.