Question

Is there any way to determine if the mouse scrolls up or down using the Mousewheel handler on a sub? eg

Private Sub PictureBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel

if mousewheel.scrollup then
        UserZoom = UserZoom + 0.05
        Me.Refresh()
end if


End Sub

I want to be able to adjust the value of userzoom up or down according to if the mouse is wheeled up or down. Any help would be appreciated guys

Was it helpful?

Solution

Check the Delta property of the MouseEventArgs:

Sample code:

Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
    If e.Delta > 0 Then
        Trace.WriteLine("Scrolled up!")
    Else
        Trace.WriteLine("Scrolled down!")
    End If
End Sub

OTHER TIPS

Figured it out.

e.delta passes either negative or positive values according to if the mouse is scrolled up or down!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top