我要移動一個按鈕鼠標,一切正常,但是當我在按鈕的窗口,左邊和頂部的按鈕的鼠標移動(左上角)將光標定位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