Spurious MouseMove events

I've got a MouseMove event handler on a PictureBox control in my C# WinForms application. I also have a MouseDown event handler but I don't think that's relevant. The MouseDown handler simply captures the current scroll position of the Panel object that contains the PictureBox. The MouseMove handler checks how much the mouse has moved and adjusts the scroll position by the corresponding amount, allowing the user to "drag" the image and scroll it.

The problem is that after I first move the mouse, I get spurious movement messages for as long as I hold down the mouse button, even though the mouse isn't moving. These movement messages seem to oscillate between two values.

I suspect there's some kind of interaction between changing the scroll position of the containing Panel object and the perceived mouse position over the PictureBox, although if that was the case I would have thought the perceived movement would have been monotonic, i.e. always moving the same direction.

Can anyone point out anything obviously stupid I might be forgetting

Thanks,
Doug Harber


Answer this question

Spurious MouseMove events

  • Spurious MouseMove events