How to remove gray background on MDI parent form?

Dylan picture Dylan · Jul 27, 2009 · Viewed 15.8k times · Source

What I'm trying to do is draw some glass on a form marked as an mdi container. However as soon as the IsMdiContainer is set, the form adds an MdiClient to it's list of Controls. At this point something happens to the parent form - almost like a dark gray panel is being docked to the entire form onto which the MdiClient is being placed on.

I then do is the following to move the MdiClient control out of the way a bit:

    foreach(var c in Controls)
    {
        if(c is MdiClient)
        {
            var client = (MdiClient)c;
            client.BackColor = Color.Red;
            client.Dock = DockStyle.None;
            client.Size = new Size(this.Width-100, this.Height);
            break;
        }
    }

This then makes the actual MdiClient area smaller so we can see what is behind it (the bit which hosts the children forms) and it is blatantly obvious that the parent form is not painting or something.

As can be seen here: http://img525.imageshack.us/img525/8605/mdiglassproblem.png

I now need to somehow get the area behind the MdiClient (dark gray part which is rendered white on the glass section) to go away.

Any ideas?

PS - Glass is being rendered using DwmExtendFrameIntoClientArea method in Vista.

Answer

Wolverine picture Wolverine · Nov 21, 2013

I think this is perfect enough.

foreach (Control ctrl in this.Controls)  
{    
    if (ctrl is MdiClient)  
    {  
        ctrl.BackColor = Color.LightGray;  
    }
}