0
votes

I have a line of code to forbid all possibilities to resize the window of my application.

this.ResizeMode = ResizeMode.NoResize;

Through this the maximize and minimize button on the top right of the window are not shown and you cannot maximize the window by double clicking the menubar.

I thought it works but then I found out that you can minimize the window with a double click on the menubar. I was very confused that this is possible. Has someone an answer to this question that you can not maximize the window with the double click but it is possible to minimize it?

1
by minimize do you mean it goes down into the tool bar at the bottom?psoshmo
minimize and maximize is different from resizing. That line of code should not affect minimize and maximize behavior.M.kazem Akhgary
@psoshmo, maybe i described it a bit wrong, with the double click the window DON'T goes in the toolbar, it only resizes to a smaller size, because my standart size is maximized, but after making the window smaller(which should not be allowed) it is not possible to make the window with a double click again to maximize.Florin M

1 Answers

0
votes

You can easily prevent minimization my detecting the change with the Resize event and setting it back to its original size.

NOTE: You will see the window minimize briefly and then come back.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.Resize += new EventHandler(Form1_Resize);
    }

    void Form1_Resize(object sender, EventArgs e)
    {
        if (WindowState == FormWindowState.Minimized)
        {
            this.WindowState = FormWindowState.Normal;
        }

    }
}