问题描述
症状;
用户拖动窗口底部使窗口更长,然后窗口框架冻结,以至于不能调整大小或移动。
User drags the bottom of the window to make the window longer, the frame of the window then freezes so that it cannot be resized or moved.
窗口中的应用程序UI仍然显示响应。这只发生在Window 10上,在Windows 7上不会发生。
The application UI within the window still appears to respond. This only happens on Window 10, it does not happen on Windows 7.
相关应用程序代码;
为应用程序窗口调整委托大小,应用程序
为窗口高度指定一个值,以保持窗口布局的美观,在这种情况下防止窗口超出给定高度。
Within the Resize Delegate for the Application window, the application assigns a value to the Window Height in order to maintain the esthetics of the window layout, in this case preventing the Window from growing beyond a given height.
Window冻结与Resize Delegate中的Height值的分配直接相关。
The Window freezing is directly connected to the assignment of a value to Height, within the Resize Delegate.
public partial class Form1 : Form
{
int Initial_Height;
public Form1()
{
InitializeComponent();
Initial_Height = this.Height;
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.Height > Initial_Height) { this.Height = Initial_Height; }
}
}
观察;
上面的简单示例可能需要大力拖动窗口底部来刺激问题。首次发现问题的更复杂的应用程序会立即显示问题。
The simple example above may require vigorous dragging of the bottom of the window to stimulate the problem. The more complex application where the problem was first discovered, shows the problem instantly.
在直接在硬件上运行的Windows 10实例上,这个问题很容易激发。对于在虚拟机中运行的Windows 10实例(至少在我正在使用的VM实例中),这个问题更难以激发。建议一些
种类的竞争条件。
The problem is easy to stimulate on an instance of Windows 10 running directly on hardware. The problem is more difficult to stimulate on an instance of Windows 10 running in a Virtual Machine (at least in the VM instance that I am using). Suggesting some kind of race condition.
此问题并非特定于语言或开发工具链。在使用C#和Embarcadero Delphi编写的等效示例应用程序中也会出现同样的问题。
This problem is not specific to a language or development tool chain. The same problem occurs in equivalent sample applications written in C# and Embarcadero Delphi.
推荐答案
public partial class Form1 : Form
{
public Form5()
{
InitializeComponent();
MaximumSize = new Size( SystemInformation.PrimaryMonitorMaximizedWindowSize.Width, this.Height );
}
}
这篇关于用户启动的窗口调整大小导致窗口“冻结”在Windows 10上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!