Jumping mouse coordinates
Hello,
I've got a question regarding the coordinates I get for my mouse position. I'm rather rusty at the moment with my C# and I've started a new project to pick it back up.
I'm currently trying to move a pictureBox and I'm using the onMouseMove event to trigger the update for my mouse coordinates. But the coordinates I get from my mouse are somehow jumping between values.
I'm guessing this has something to do with the different forms, but I'm not sure. I'm hoping anyone can clear this out for me.
I'm using .net framework 3.5 and using VS2008. If more information is needed, please ask!
Re: Jumping mouse coordinates
Quote:
I'm guessing this has something to do with the different forms
This is kind of an important detail... can you explain it more? Are you trying to drag a picture box from one form to another? Are you using coordinates relative to each form?
Re: Jumping mouse coordinates
Basically I have the main form and a panel. Inside the panel I have the pictureBox and I'm trying to move the picturebox.
Code:
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
pictureBox1.Location = new Point(e.X, e.Y);
textBox1.Text = "X: " + e.X + " Y: " + e.Y;
Refresh();
}
}
Re: Jumping mouse coordinates
I'd capture MouseDown/MouseUp and cache the coordinates.
On MouseDown, capture the X/Y location, and on MouseUp, capture the X/Y location and set the picturebox to the new location if it's different.
Re: Jumping mouse coordinates
That would probably work, but I'm more interested in making the pictureBox move instead of just change location by a flash.
Re: Jumping mouse coordinates
I got it working myself in a completely different way. But thanks for the thoughts anyway!
Greetz Wiizle
Re: Jumping mouse coordinates
Quote:
Originally Posted by
Wiizle
I got it working myself in a completely different way.
would you share your solution with us?