Hello, I wondering why the mouseMove event is different vs the normal controls?
In the normal objects the MouseMoveEvent continues if the mouse was pressed(Down) and the cursor leaves the control.
By ex, I have the following code:
Public Class Form1
Private mbox As New MoveBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mbox.Location = New Point(30, 30)
Me.Controls.Add(mbox)
End Sub
End Class
Public Class MoveBox
Inherits PictureBox
Private _isActive As Boolean
Public Sub New()
Me.Size = New Size(10, 10)
Me.BackColor = Color.Blue
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseDown(e)
_isActive = True
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseUp(e)
_isActive = False
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseMove(e)
If Me._isActive Then
Me.Location = Me.Location + e.Location - New Point(Me.Width \ 2, Me.Height \ 2)
End If
End Sub
End Class
This code allows move a pictureBox with the pressed mouse.
But when I try to inherit the OvalShape, The code does not work, cause the MouseMove event is not generated when the cursor leaves the shape control...
Best regards,
Sergiu