usercontrol把form占满还怎么实现用户区拖动窗口?
如果form未被占满,那么点击没有被占用的地方,可以通过下面方式实现拖动窗口:
private System.Drawing.Point mousePosition;
private void FloatingToolForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.mousePosition.X = e.X;
this.mousePosition.Y = e.Y;
}
}
private void FloatingToolForm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Top = Control.MousePosition.Y - mousePosition.Y;
this.Left = Control.MousePosition.X - mousePosition.X;
}
}
只要在构造方法里加上
this.MouseDown += FloatingToolForm_MouseDown;
this.MouseMove += FloatingToolForm_MouseMove;就可以了。
可是如果form被一个usercontrol给占满了,在那个usercontrol的构造方法里,和这个form的构造方法里都加了这两个委托还是不行。怎么回事,怎么办呢?
------解决方案--------------------http://bbs.csdn.net/topics/320157403
2L
------解决方案--------------------