我想知道在windows7上有一个功能,当你的鼠标点击窗体的左/右上角时,它会自动将窗口大小调整为屏幕的一半。我正试着用我的MDI孩子做到这一点。这是我的代码,但是函数不起作用。
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Form1 f1 = new Form1();
if (e.X == f1.Width/2 - 30)
{
Form activeChild = this.ActiveMdiChild;
activeChild.Width = this.Width / 2;
activeChild.Height = this.Height;
activeChild.Dock = DockStyle.Left;
}
}发布于 2011-03-07 13:55:13
您可以尝试在实际子窗体的Move事件上执行此操作。在任何情况下,基于Form1的新实例处理事件都不会很好地工作。无论如何,下面是一些代码,就像它在孩子内部的样子一样。(虽然很难看,但它至少做了一些事情。)
private void SubForm_Move(object sender, EventArgs e)
{
if (Location.X <= 0)
{
Width = MdiParent.Width / 2;
Height = MdiParent.Height;
Location = new Point(0,0);
Dock = DockStyle.Left;
}
}https://stackoverflow.com/questions/5216065
复制相似问题