NEWBIE - MDI Questions

Topics: CAB & Smart Client Software Factory
Oct 25, 2007 at 2:59 AM
I've been playing with cab/scsf for a few day now and think I have a basic handle on it. However, I have not been able to figure out how to create a basic MDI style app. I found a post on codeproject, but i also found it to advanced.
Can anyone please point me to some basic info about how to create a mdi app. VB code would be good, since that is what the app I am upgrading is written in, but C# is fine.

All I really need is a few things:
1. How do I make tha main shell an MDI container
2. how do I show forms/smart parts in the mdi container.

Please keep in mind that I am porting an app, I do not have the option of a complete GUI redesign.

I'm sure there is sample code for this somewhere, but I can't find it. Any help would be really appreciated.
Oct 26, 2007 at 3:05 PM

If you want to show your views in MDI child forms you should use the MdiWorkspace.
The MdiWorkspace enables you to show and hide controls and SmartParts in MDI child forms. It is based on the WindowWorkspace type and extends this to display the SmartParts as MDI child forms. Its implementation of the IWorkspace methods can show, hide, and close a new window in which the SmartPart displays. It receives the SmartPartInfo hint object in the Show method to set the title of the child form.

The MdiWorkspace needs the form where will be placed as a parameter in its constructor and need and empty Shell. Therefore you will need to change your Shell layout removing all your previous workspace and all the containers (you only can keep in the Shell your MenuStrips, StatusTrips and ToolStrips). Then you will need to add the MdiWorkspace in the following way:

// ShellApplication.cs
Protected Overrides Sub AfterShellCreated()
    RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainMenu, Me.Shell.MainMenuStrip)
    RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainStatus, Me.Shell.MainStatusStrip)
    RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainToolbar, Me.Shell.MainToolbarStrip)
    'Add the MdiWorkspace to the Shell.
    Dim mdiWorkspace As New MdiWorkspace(Me.Shell)
    RootWorkItem.Workspaces.Add(mdiWorkspace, WorkspaceNames.MdiWorkspace)
End Sub
In all your modules you can use the MdiWorkspace as an usual workspace.

I recommend you to read the following thread:
Here you can find an example about how to use this workspace:
Please let me know if this helps.

Mariano Converti
Oct 26, 2007 at 3:37 PM
Excellent! Thanks a million.