我没试过……
查查相关的类吧
你、的意思是不是要实现把应用程序拖来拖去啊
我这有经典代码:
private void MainForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_mousePosition = new Point( e.X, e.Y);//基于窗体的坐标
_formPosition = this.Location;
isMouseDown = true;
}
// Debug.WriteLine( _mousePosition.X.ToString() );
}
private void MainForm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (isMouseDown)
{
Point currentMousePosition = Control.MousePosition;//光标相对于屏幕左上角的坐标
Point location = new Point(
(currentMousePosition.X - _mousePosition.X),
(currentMousePosition.Y - _mousePosition.Y));
this.Location = location;
//
// Debug.WriteLine( "this.Location.X:" + this.Location.X.ToString() );
// Debug.WriteLine( "Control.MousePosition.X:" + Control.MousePosition.X.ToString() );
// Debug.WriteLine( "Location.X:" + location.X.ToString() );
}
}
private void MainForm_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
这三个 方法@!分别控制用用程序在电脑屏幕上的坐标!