I have a picturebox bigger than the form, the form have AutoScroll set to on
So to scroll the picturebox without using the scrollbars i added this code:
Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Middle Then
Dim DeltaX As Integer = (m_PanStartPoint.X - e.X)
Dim DeltaY As Integer = (m_PanStartPoint.Y - e.Y)
Me.AutoScrollPosition = _
New Drawing.Point((DeltaX - Me.AutoScrollPosition.X), _
(DeltaY - Me.AutoScrollPosition.Y))
End If
It works correctly if i drag and drop the picturebox for like 2 seconds, but if i hold the middle mouse button for like 5 seconds it will give me a stack overflow exeption even that its not even a loop
Is there a way to 'fix' that stack overflow? Im not sure what a Stack Overflow exactly is so im confuse about what to do.
mouse down event
Private Sub PictureBox1_Mousedown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown m_PanStartPoint = New Point(e.X, e.Y)