您的位置:首页 > 其它

鼠标拖动窗体功能

2012-06-10 10:39 204 查看
static int cx = 0;
static int cy = 0;
static bool move = false;

private void label1_MouseDown(object sender, MouseEventArgs e)
{
cx = e.X;
cy = e.Y;
move = true;
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (move)
{

this.Left += e.X - cx;
this.Top += e.Y - cy;
}
}

private void label1_MouseUp(object sender, MouseEventArgs e)
{
move = false;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: