MDI Problems

Am getting the following problems with MDI forms:

1. Child forms set to maximised at design time do not appear maximised when shown.

2. Icons of maximised child forms do not show in the control box menu until the MDI form is resized.

3. I can't get the toolbar buttons of child forms to merge with those of the MDI form. I've set the AllowMerge property of the MDI form toolstrip to True, and MergeAction of the child form toolstrip buttons to Append and Insert, but they just don't appear. EDIT - OK, I can fix this with the ToolStripManager.

4. I want the toolstrip to be draggable to any side of the MDI form. I'd use a single toolstrip container, but that has a panel in the middle which doesn't leave any space for child forms to be displayed. So I'm trying to do this with a toolstrip container on each side of the MDI form. That's OK, but there's no autosize property for the toolstrip containers, and it's proving very hard to set their widths and heights appropriately. This must be a very standard thing to want to do and I was wondering if there was any code somewhere I could download to see the accepted way to achieve this. EDIT - OK there's a solution here ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref17/html/T_System_Windows_Forms_ToolStripPanel.htm

Grateful for some help. Note that 1 and 3 were not problems in the Beta version, and nor was the sizing of toolstrips referred to in 4.


Answer this question

MDI Problems

  • St3veM

    Sadthats my problem also! I have no ideas yet but I am looking.

    Thanks,

    Sam

  • Quintesv

    I tried your code both after calling the child form's Show method, and on my MdiChildActivate handler, and the menuStrip1.Items[0] always returns my File menu, whether the child is maximized or not.

    Luis Alonso Ramos


  • Varsha Sharma

    I'll try that code tomorrow morning. But where did you put it in the MdiChildActivate event handler

    Thanks!

    Luis Alonso Ramos


  • trevA

    Yes it is.

    Do you want problem number 6 I layout my top level menus in the designer as I want them (File, Edit, View, Window, Help for example) and when I run the app, they appear all mixed up (File, View, Help, Edit, Window or something like that.)

    This MDI support with ToolStrips is really leaving much to be desired.

    Luis Alonso Ramos


  • SJINDAL

    I'm using Visual Studio 2005 Professional, with C#. I didn't use the TypeName VB function, but I used the GetType method and ran the code through the debugger, and definitely it's the File menu, and not the system menu.

    That ordering problem looks temporal. Sometimes it happens and sometimes it doesn't. I think it's more of a designer problem that sometimes messes up with the order.

    Luis Alonso Ramos


  • Bissy

    About 2, I've seen this problem a little bit different. If I maximize a MDI child window, its icon is shown. If I change to another MDI child (using the Window menu), then the icon and the child minimize, maximize and close buttons are hidden until the window is resized (repaints I've called Invalidate and Refresh on the MenuStrip during the MdiChildActivate event and nothing happens.)

    And about 4, I found a solution here a few days ago that basically consists on not using ToolStripContainers but ToolStripPanels (you'll have to add them to your toolbox). Put one panel on each side on the form and you'll be all set. You'll have to be careful to set the correct order (use the Document Outline) because you don't want your toolbar docked below your status bar.

    I have a little sample applciation at my office that I could email you on Monday if you still haven't fixed the problem.

    I hope this helps!

    Luis Alonso Ramos


  • doggie

    What version have you got I've got VB Express 2005. If you have the same then I can't think why it isn't working for you.

    For the ordering problem, could this be something to do with the toolstrip merging that VB carries out for an MDI form and its active child The logic involved in that is awfully fiddly and very hard to get right.

  • Ahmed Sajwani

    Immediately after calling the ChildForm's Show method, but your suggestion might not be a bad idea instead.

  • Raj KKK

    Is menuStrip1 set as the MDI Form's MainMenuStrip

  • Techno_Dex

    I have fixed 2 with the following code:

                Dim r As ToolStripMenuItem
                Try
                    r = Me.mnsMain.Items(0)
                    If TypeName(r) = "SystemMenuItem" Then
                        Dim t As Long
                        t = mnsMain.Height
                        r.Image = ChildForm.Icon.ToBitmap
                        mnsMain.Height = t
                    End If
                Catch ex As Exception
                    Debug.Print("Failed to set system menu item.")
                End Try

    I don't get the problems you do with selecting a different form through the Window menu, but trying this out has revealed a further problem - the form selected in this manner appears in a normalised state for a short while before being maximised. Problem no. 5.

    For problem 4 I had found the solution you're referring to in the link that I have now added to my original post, but thanks anyway.

  • MDI Problems