我要移动一个按钮鼠标,一切正常,但是当我在按钮的窗口,左边和顶部的按钮的鼠标移动(左上角)将光标定位POS机。移动控件通过鼠标
我不希望出现这种情况。我的代码中的错误在哪里?
private void button1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
clicked = true;
}
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
if (clicked)
{
Point p = new Point();//in form coordinates
p.X = e.X + button1.Left;
p.Y = e.Y + button1.Top;
button1.Left = p.X;
button1.Top = p.Y ;
}
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
clicked = false;
}
ClientToScreen和ScreenToClient坐标 – 2011-02-08 16:02:07