MouseWheel Event

FYRe

Freshman
Joined
Aug 10, 2005
Messages
32
Location
Singapore
I am trying to create an event which, when you scroll the mouse wheel UPwards, an event occur, & when you scroll the mouse wheel DOWNwards, an event will occur.

Is anyone familiar with using MouseWheel Event, in VS 2003 ? or is there some other Event that can be used? I need example/s or maybe tutorial/s a.s.a.p. for my project.

thks,
FYRe
 
Mousewheel event

This is from a VS 2002 app. The mousewheel event is not in the list of events but exists (found that on this site).
Code:
  Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseWheel
    If e.Delta < 0 Then
      ' Routine when mouse scroll down
    Else
      ' Routine when mouse scroll up
    End If
  End Sub
 
Mouse Wheel Event/ Rotation

rustyd said:
This is from a VS 2002 app. The mousewheel event is not in the list of events but exists (found that on this site).
Code:
  Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseWheel
    If e.Delta < 0 Then
      ' Routine when mouse scroll down
    Else
      ' Routine when mouse scroll up
    End If
  End Sub



thks... it works! Now I have another query,
But how do I know how many "notch" the wheel is rotated?
- Each mouse wheel rotation have a notch.

- How do I determine how many notches have been turned; both forward and backwards ?

:confused:
 
Add this line of code and the delta value produced by scrolling will appear in your output window.
Code:
    Console.WriteLine("e.delta = " & e.Delta.ToString)

Mousewheel forward, or up, e.delta = 120;
Mousewheel backward, or down, e.delta = -120;
I noticed when I aggressively scrolled the value changed to 240 depending on the direction I scrolled.

From scrolling up and down I get the following output:
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -240
e.delta = -120
e.delta = -120
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -240
e.delta = -120
e.delta = -120
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -240
e.delta = -240
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 120
e.delta = 120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = -120
e.delta = 120
e.delta = 120
e.delta = 240
e.delta = 240
e.delta = 240
e.delta = 120
 
Ok, let me get this clearly, you mentioned that:

Mousewheel forward, or up, e.delta = 120;
Mousewheel backward, or down, e.delta = -120

does a "Mousewheel forward/backward" means ONE notch of a Mouse Scroll? or generally scrolling the MouseWheel ?

Are the statements below TRUE ?

Meaning ONE notch forward: e.Delta = 120
TWO notch forward: e.Delta = 240
THREE notch forward: e.Delta = 360 etc...

Meaning ONE notch backward: e.Delta = -120
TWO notch backward: e.Delta = -240
THREE notch backward: e.Delta = -360 etc...
 
I know that up is negative, down is positive. It seems (+/-) 120 is the magic number, but I also occassionaly received (+/-) 240 when I scrolled aggressively. I don't know where you're getting 360.

Basically, check for positive or negative to determine the direction of the scroll.
 
According to ducumentation on MouseWheel event arguments, one mouse wheel click gives a delta of 120 (+ or -), 'aggressive scrolling' may then register more than 1 click between events being raised.
 
Back
Top