MouseWheel, determining up and down scrolling events
Asked Answered
B

2

5

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

Baudin answered 4/3, 2010 at 10:6 Comment(0)
C
21

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
Cobaltite answered 4/3, 2010 at 10:14 Comment(0)
B
0

Figured it out.

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

Baudin answered 4/3, 2010 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.