本文介绍了取消 WinForm 最小化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个禁用了 minimumMaximizeClose 按钮​​的 winform,但是如果有人在任务栏中按下它,它仍然会最小化.我想防止这种情况发生.

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.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

您可能会发现他们在 SizeChanged 事件并检查 WindowState,如果它被设置为 最小化 然后将其设置回 正常.不是最优雅的解决方案,但应该可行.

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.

例如

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

这篇关于取消 WinForm 最小化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:00