MouseWheel defining up and down scroll events

Is there a 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 userzoom value up or down so that the mouse sways up or down. Any help would be appreciated by the guys.

+4
source share
2 answers

Check out the Delta property for MouseEventArgs:

Code example:

 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 
+15
source

Figured it out.

e.delta transmits either negative or positive values ​​depending on whether the mouse scrolls up or down!

0
source

Source: https://habr.com/ru/post/1303104/


All Articles