tags:

views:

457

answers:

2

When creating a MDI parent, the entire "inside" of the form is made the MDI region.

If you add a menustrip to the MDI parent, the MDI region is scaled down a bit to make room for the menustrip.

But if you add a panel to the top of the MDI parent, the entire inside is still the MDI region. Which means that you can move MDI children up behind the panel, and hide their title line. If you move MDI children behind a menustrip, scrollbars appear, and you can scroll higher up to access the title line. But the scrollbars doesn't appear when you are using a panel instead of a menustrip. Because the MDI region doesn't know about the panel, I suppose.

How can I scale the MDI region to start below a given Y value?

A: 

Well the short of it is you can't modify the MDI parent/container window in .Net. The window is still there and you can find it with Win32 apis if you really desire.

However, what you describe as your goal is doable. Since there isn't any code I can't tell what your doing wrong, but the following demonstrates this working:

public class Form1 : Form
{
 static void Main(string[] args) { Application.Run(new Form1()); }

 public Form1()
 {
  this.IsMdiContainer = true;
  Panel test = new Panel();
  test.Dock = DockStyle.Top;
  test.Height = 100;
  this.Controls.Add(test);

  Form child = new Form();
  child.MdiParent = this;
  child.Text = "Child";
  child.Show();
 }
}
csharptest.net
Thanks. I solved it by adding a OnLocationChanged event, and checking if the Y value was lower than the panel's height. I don't like it, though.
Erlend D.
A: 

If csharptest.net is right, and one cannot change the MDI region, I've found two ways to do it:

  1. Add multiple MenuStrip objects (each of those moves the MDI region 24 pixels lower on the parent form).
  2. Use the LocationChanged event of the MDI children, and manually check that their Y value is larger than the border you wish to keep them below.
Erlend D.