ToolStripContainer & Changing MDI layout

Docking/MDI for Windows Forms Forum

Posted 17 years ago by Philip Dam
Version: 2.0.83
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
I'm using the ToolStripContainer to handle a MenuStrip and the DockManager. Then I dock Forms inside the UIStudio area. This works fine when I use TabbedMdiMode but when I want to change to Standard mode on the fly I get an error ("Standard MDI may not be set unless the host container control is a Form.")
I have tried assigning the HostContainerCtrl to a Form but then I run into initialization problems.

I have a project to demonstrate it but I can't see how I should summit it, via this support-forum interface !!

Comments (7)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philip,

Any time you email us you can use the support email address found on our Contact Us page.

But that error does make sense. Because only a Form is capable of hosting standard MDI mode. So if you want to support both standard and tabbed MDI modes, then you need to make your host container the Form. It's best to start off that way instead of switching it at run-time.


Actipro Software Support

Posted 17 years ago by Philip Dam
Avatar
OK, I simply cant make it work that way.

1. For ending the initialization of the dockmanager the form must be toplevel
2. For assigning the form to the contentpanel it cannot be toplevel

Also making it an mdi container seems to be impossible with similar conflicts

How do I move on. ?? See ex. below

         private void ConnectToolStripContainerAndDock()
        {
            this.components = new Container();
            this.dockManager = new DockManager(this.components);

            this.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dockManager)).BeginInit();

            this.IsMdiContainer = true;

            this.dockManager.DefaultMdiWindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.dockManager.DocumentMdiStyle = ActiproSoftware.UIStudio.Dock.DocumentMdiStyle.Standard;
            this.dockManager.NextWindowNavigationEnabled = true;

            // Add menu with two entries.
            // one to create a new form and another to toggle mdi-mode
            toolStripContainer = new ToolStripContainer();
            toolStripContainer.Dock = DockStyle.Fill;
            toolStripContainer.TopToolStripPanel.Join(ms);

            // Form used as parent for UIstudio dock area
            Form formContainer = new Form();
            formContainer.TopLevel = false;
            formContainer.Dock = DockStyle.Fill;
            //formContainer.IsMdiContainer = true;

            toolStripContainer.ContentPanel.Controls.Add(formContainer);
            this.dockManager.HostContainerControl = formContainer;

            this.Controls.Add(toolStripContainer);
    
            ((System.ComponentModel.ISupportInitialize)(this.dockManager)).EndInit();

            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form f = new Form();
            f.Name = "ChildForm";
            f.MdiParent = this;
            f.Visible = true;
            f.TopLevel = false;
            f.FormBorderStyle = FormBorderStyle.None;
            f.Dock = DockStyle.Fill;
            string key = "1";
            string text = f.Name;

            DocumentWindow documentWindow = new DocumentWindow(dockManager, key, text + key, 0, f);
            documentWindow.Activate();
        }

        private void toggleMDIModeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dockManager.DocumentMdiStyle == DocumentMdiStyle.Tabbed)
                dockManager.DocumentMdiStyle = DocumentMdiStyle.Standard;
            else
                dockManager.DocumentMdiStyle = DocumentMdiStyle.Tabbed;
        }
NB!
It's a little confusing if you read the documentation. In the chapter "Using the DockManager with ToolStripContainers" you recommend to use a simple usercontrol and then several places you write that mdi modes can be changed runtime. !!
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philip,

Can you email us a ZIP of your test project that you are using with this code? That would help us better see exactly what you are doing so we can get you a faster response. Thanks much!


Actipro Software Support

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philip,

Thanks for the sample project. The limitation here is because Microsoft's code, not ours. Let me explain.

Standard MDI is something that has been in Windows since the beginning. It is a system-controlled feature that can only be activated on toplevel Forms. The ToolStrip is a new control Microsoft created in .NET 2.0. The issue with ToolStripContainer is that it fills up the entire Form and overlays any standard MDI that the Form might be hosting. It's a bad design if you ask me.

This is part of the reason that with our own bar controls, we chose to make them dock on the sides of the host control instead of filling it. Therefore our own bar controls don't run into this issue.

I can dupe your issue with just Microsoft controls. Create a Form. Set it to be an MDI parent. You can see the background change color. Now add a ToolStripContainer. It fills the Form and you essentially lose your MDI capabilities.

I hope that explains it.


Actipro Software Support

Posted 17 years ago by Philip Dam
Avatar
Hi

hmm.... suppose I use only UIstudio control so I'll get both my mdi standard + tabbed mode (plus change on the fly) which I need. You write that achieving menu-merging for standard mode is easy but for tabbed mode it's impossible. I'm not sure I understand why. ?
Isn't it possible to hook up to SelectedDocumentChanged when in tabbed mdi mode and then do something like
 
   // Merge or revert merge
    if (this.ActiveMdiChild is BarMdiMergeChildForm) {
        BarMdiMergeChildForm childForm = (BarMdiMergeChildForm)this.ActiveMdiChild;
        BarManager.Merge(childForm.MenuBar, barManager.MenuBar, true);
    }
    else
        BarManager.RevertAllMerges(barManager.MenuBar);
though substituting ActiveMdiChild with something else ?? if not what would you recommend ?
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmm... I think you might have misread that part. Let me explain better. In the "Working with MDI" topic under "Merging Command Links" there are two examples. The first (that you posted above) is if you are NOT using our dock controls. The second example right below it shows you what to do instead if you ARE using our dock controls. Hope that helps.


Actipro Software Support

Posted 17 years ago by Philip Dam
Avatar
It does, thank you for your help :-)
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.