How to Mousewheel?

brainleak

Well-known member
Joined
Dec 20, 2016
Messages
54
Location
Barcelona area
Programming Experience
3-5
Why does this work:

VB.NET:
Private Sub frmMain_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
     Console.WriteLine(e.Delta)
End Sub

while this doesn't?

VB.NET:
Private Sub PictureBox1_MouseWheel(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseWheel
     Console.WriteLine(e.Delta)
End Sub
 
I'm getting event from both (of course when mouse is over picturebox).
I read somewhere this was new with Windows 10, so perhaps you're using older Windows. If this is the case, and it is not problematic to steal focus, then you could use MouseEnter event of picturebox and call its Focus method (not sure if Select method applies to picturebox control at all).
 
I'm getting event from both (of course when mouse is over picturebox).
I read somewhere this was new with Windows 10, so perhaps you're using older Windows. If this is the case, and it is not problematic to steal focus, then you could use MouseEnter event of picturebox and call its Focus method (not sure if Select method applies to picturebox control at all).
You're right, I'm using Windows 7.

However the form mousewheel event is raised even when the mouse is over the picturebox as if the latter were not there, so I think I can make do with it with just a little bit of arithmetic.
 
Back
Top