MouseMove上的堆栈溢出

时间:2014-05-20 01:57:51

标签: vb.net visual-studio-2010 visual-studio-2012 stack-overflow

我有一个比表单大的图片框,表单上的AutoScroll设置为

因此,为了在不使用滚动条的情况下滚动图片框,我添加了以下代码:

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

如果我将图片框拖放2秒钟,它可以正常工作,但是如果我按住鼠标中键5秒钟它会给我一个堆栈溢出执行,即使它甚至不是循环

有没有办法修复'堆栈溢出?我不确定Stack Overflow究竟是什么,所以我很困惑该怎么做。

  • 鼠标按下事件

    Private Sub PictureBox1_Mousedown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
    
    m_PanStartPoint = New Point(e.X, e.Y)
    

0 个答案:

没有答案