C# – mdi child form maximized windowstate – BorderStyle

cmdichildmdiparentvb.netwinforms

I want to open a child form inside parent with maximized windowstate.

I don't want to let the user minimize/ maximize/ close that child window,

so I set BorderStyle = None for childwindow and also set MaximizeBox and MinimizeBox properties to False, also set WindowState = Maximized

But when I run the program it shows all Minimize, Restore and Close buttons for that childForm in maximized state.

but if I click Restore Down then there is no border for that childForm..now No way to restore it to maximized state also..

Am I missing something? Is this a bug? What is the proper way of making it work correctly?

Best Answer

just try this one.

protected override void WndProc(ref Message m)
{
    const int WM_SYSCOMMAND = 0x0112;
    const int SC_MOVE = 0xf010;
    switch (m.Msg)
    {
        case WM_SYSCOMMAND:
            int command = m.WParam.ToInt32() & 0xfff0;
            if (command == SC_MOVE)
                return;
            break;

    }
    base.WndProc(ref m);
}
Related Topic