I'm noticing strange behaviour with System.Windows.Forms.Control.

If I press the mouse (left button), then move the mouse while still holding
it down, and then release the mouse, I get an extra set of OnMouseDown and
OnMouseUp.

So I get OnMouseDown, OnMouseUp, OnMouseDown, OnMouseUp even though the
mouse has only been pressed and released once.

Does anyone know about this? I think this is surely a bug. It's easy to
replicate. Add this code to a new user control and put an instance of the
control on a form.

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
Debug.WriteLine("OnMouseDown")
MyBase.OnMouseDown(e)
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows.Forms.MouseEventArgs)
Debug.WriteLine("OnMouseUp")
MyBase.OnMouseUp(e)
End Sub

You might have to try a few times to see it, but it usually only takes a few
efforts. It seems easier to replicate if I drag the mouse from the bottom of
the control towards the top!

Thanks in advance.

Re: Control OnMouseDown and OnMouseUp called twice - surely a bug? by Armin

Armin
Thu May 19 09:04:21 CDT 2005

"Brett" <Brett@discussions.microsoft.com> schrieb
> I'm noticing strange behaviour with System.Windows.Forms.Control.
>
> If I press the mouse (left button), then move the mouse while still
> holding it down, and then release the mouse, I get an extra set of
> OnMouseDown and OnMouseUp.
>
> So I get OnMouseDown, OnMouseUp, OnMouseDown, OnMouseUp even though
> the mouse has only been pressed and released once.
>
> Does anyone know about this? I think this is surely a bug. It's easy
> to replicate. Add this code to a new user control and put an
> instance of the control on a form.
>
> Protected Overrides Sub OnMouseDown(ByVal e As
> System.Windows.Forms.MouseEventArgs)
> Debug.WriteLine("OnMouseDown")
> MyBase.OnMouseDown(e)
> End Sub
>
> Protected Overrides Sub OnMouseUp(ByVal e As
> System.Windows.Forms.MouseEventArgs)
> Debug.WriteLine("OnMouseUp")
> MyBase.OnMouseUp(e)
> End Sub
>
> You might have to try a few times to see it, but it usually only
> takes a few efforts. It seems easier to replicate if I drag the
> mouse from the bottom of the control towards the top!
>
> Thanks in advance.


I'd be surprised if it was reproducable here. Means, it is not.

Armin