怎样用C#获取鼠标点击的坐标以及模拟鼠标的拖动动作
2014-12-16
展开全部
展开全部
private Point formPoint;
private void panel_FTitle_MouseDown(object sender, MouseEventArgs e)
{
formPoint = Cursor.Position;
}
private void panel_FTitle_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int px = Cursor.Position.X - formPoint.X;
int py = Cursor.Position.Y - formPoint.Y;
this.Location = new Point(this.Location.X + px, this.Location.Y + py);
formPoint = Cursor.Position;
}
}
private void panel_FTitle_MouseDown(object sender, MouseEventArgs e)
{
formPoint = Cursor.Position;
}
private void panel_FTitle_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int px = Cursor.Position.X - formPoint.X;
int py = Cursor.Position.Y - formPoint.Y;
this.Location = new Point(this.Location.X + px, this.Location.Y + py);
formPoint = Cursor.Position;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询