0
votes

Whenever I minimize or maximize an MDI Parent form while it has a child form maximized, the height of the MDI Parent shrinks by roughly 20px.

I started out with .Net Framework 4.0 and had this problem, so I tried other versions and continued to have problem.

Here are some steps to replicate (trying 4.7.1 this time):

  1. Closed all instances of VS2017 and open VS2017.
  2. File > New > Project.
  3. Name: MdiTest2; Framework 4.7.2; Hit OK.
  4. Set Form1 "IsMdiContainer" to True.
  5. Right-click project > Add > Windows Form... Called this ChildForm.vb.
  6. Went back to Form1, doubl-clicked form.
  7. Set Form1 load event to following:

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim frm As New ChildForm
        frm.MdiParent = Me
        frm.WindowState = FormWindowState.Maximized
        frm.Show()

    End Sub
  1. Started debugging
  2. Drag Parent form somewhere so that you'll notice changes to height of form (align the bottom of form with another form, icon, or top of taskbar).
  3. Maximize the form and then click restore button... Notice form resizes
  4. Minimize the form and then click the icon for it on the taskbar...
  5. Notice the form resizes (for me), the top of the form stays at original location, but the bottom border moves up ~20px.
  6. If I continue to click the apps icon on taskbar, it will continue to shrink ever time the form is restored.

Is anyone able to replicate this or is this just a bug on my machine? My resolution is 2560x1440 and scaling is set to 100%. If I change AutoScaleMode on Form1 and ChildForm from "Font" (default) to "None", I still have this problem. If I do not have an MDI Child form maximized when I Minimize/Maximize the MDI Parent, the MDI Parent height does not shrink when restored.

1

1 Answers

1
votes

After doing a lot of searching and not finding anyone else with this bug, I started asking myself: "why would others not have this problem". Well, my program will not have a MenuStrip, but almost all MDI parent forms have one. So, on a hunch, I added a menu strip to the form and it fixed my problem. I then set the visibility of the MenuStrip to false and tested... it still works with MenuStrip visibility set to false.