2016-09-29 23 views

回答

0

您需要處理多個事件。您需要捕獲MouseWheel事件和MouseDown/MouseUP事件。

Private mouseDown As Boolean = False 
Private Sub Form1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel 
    If e.Delta > 0 And mouseDown Then 
     Console.WriteLine("Scrolling with button down") 
    Else 
     Console.WriteLine("Button Not down whilst scrolling") 
    End If 
End Sub 

Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown 
    If e.Button = MouseButtons.Middle Then 
     mouseDown = True 
    End If 
End Sub 

Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp 
    If e.Button = MouseButtons.Middle Then mouseDown = False 
End Sub 

當中間鼠標關閉時寫入一個私有變量,然後在wheel處理程序中運行您的條件語句。

+0

感謝它的工作:D:D –