Windows 7 鼠标左键自动调整大小?
我想知道 Windows 7 上有一个功能,当您的鼠标点击窗体左/右顶部时,它会自动将窗口大小调整为屏幕的一半。我正在尝试用我的 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;
}
}
I was wondering on windows 7 there is the function that when your mouse hits the form left/right top it will auto size the window to half the screen. I am trying to do that with my MDI Child. Here is the code that I have, however the function does not work.
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试在实际子窗体的 Move 事件上执行此操作。在任何事件中,基于 Form1 的新实例处理事件都不会很好地工作。无论如何,这是一些在子进程内部查看的代码。 (丑陋,但它至少做了一些事情。)
You might try doing that on the Move event of the actual child form. Handling the event based on a new instance of Form1 in any event won't work very well. Anyhow, here's some code as it would look inside the child. (Ugly, but it at least does something.)