Cancel A WinForm Minimize?

前端 未结 4 846
名媛妹妹
名媛妹妹 2021-01-03 03:06

I have a winform with the minimizeMaximizeClose buttons disabled, but still if someone presses it in the task bar, it will minimize. I want to prevent this from happening.

4条回答
  •  温柔的废话
    2021-01-03 03:21

    You could probably catch them changing it in the SizeChanged event and check the WindowState, if its been set to Minimized then set it back Normal. Not the most elegant solution but should work.

    eg.

    private void myForm_SizeChanged(object sender, System.EventArgs e)
    {
       if (myForm.WindowState == FormWindowState.Minimized)
       {
           myForm.WindowState = FormWindowState.Normal;
       }
    }
    

提交回复
热议问题