bool bPictureBoxDragging = false;
Point oPointClicked;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
PictureBox p = (PictureBox)sender;
pictureBox1.Cursor = Cursors.Hand;
bPictureBoxDragging = true;
oPointClicked = e.Location;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (bPictureBoxDragging)
{
DoubleBuffered = true;
Point oMoveToPoint;
oMoveToPoint = pictureBox1.PointToScreen(e.Location);
oMoveToPoint.Offset(oPointClicked.X * -1, oPointClicked.Y * -1);
pictureBox1.Location = oMoveToPoint;
}
} private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
bPictureBoxDragging = false;
pictureBox1.Cursor = Cursors.Arrow;
} 大家帮我看看,为什么鼠标按下移动的时候图片会跳一下??怎么解决?
Point oPointClicked;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
PictureBox p = (PictureBox)sender;
pictureBox1.Cursor = Cursors.Hand;
bPictureBoxDragging = true;
oPointClicked = e.Location;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (bPictureBoxDragging)
{
DoubleBuffered = true;
Point oMoveToPoint;
oMoveToPoint = pictureBox1.PointToScreen(e.Location);
oMoveToPoint.Offset(oPointClicked.X * -1, oPointClicked.Y * -1);
pictureBox1.Location = oMoveToPoint;
}
} private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
bPictureBoxDragging = false;
pictureBox1.Cursor = Cursors.Arrow;
} 大家帮我看看,为什么鼠标按下移动的时候图片会跳一下??怎么解决?
pictureBox1.Location = oMoveToPoint//有这句话,图片的位置当然会随鼠标变化了
Point lastPoint = Point.Empty;
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
PictureBox box = sender as PictureBox;
if (box.Capture)
{
Point loc = box.Location;
loc.Offset(e.Location.X - lastPoint.X, e.Location.Y - lastPoint.Y);
box.Location = loc;
}
}private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
lastPoint = e.Location;
}
这句话有问题,改成楼上的方法,应该对了
问题解决 谢谢hbxtlhx(平民百姓)