Results 1 to 6 of 6

Thread: [RESOLVED] [2005] MouseWheel Event

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Resolved [RESOLVED] [2005] MouseWheel Event

    I am have an issue where I need to know when the mousewheel has stopped scrolling. I have a procedure that is started when the MouseWheel event is raised. This procedure just keeps going until I call Stop, which I need to do when the Mouse wheel is not being scrolled any more. I also can call stop right after I call start because of the jerkiness it causes. Does anyone have an idea how I can do that?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] MouseWheel Event

    No love for me?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] MouseWheel Event

    As far as your app is concerned the mouse wheel doesn't start and stop scrolling. The MouseWheel event is raised for each standard increment that the wheel is scrolled. There is no measure of whether the wheel is moving or not. The user might turn the wheel slowly, in which case the MouseWheel event will be raised at larger intervals, or the user might turn the wheel quickly, in which case the MouseWheel event will be raised at smaller intervals. Either way there is no indication of whether it was a continuous movements or a series of discrete movements.

    You could use a hack to simulate what you want with a Timer, where each time the MouseWheel event is raised you set a variable to the current time and enable a Timer. Each time the Timer Ticks it checks the last time the MouseWheel event was raised and if it was more than a specified amount of time then it disables itself and stops whatever process was started when the MouseWheel event was raised.

    I would question whether you're actually using the MouseWheel event properly. In the MouseWheel event the e.Delta property tells you how much the wheel was turned and that is intended to be used to increment or decrement some value. If you haven't already you should read the help topic for the Control.MouseWheel event.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] MouseWheel Event

    This isn't something I wanted to do, but figured out a hack that will work good enough. If the user wants to use this functionality they have to click the mouse wheel then rotate it.

    But thanks for your input.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] MouseWheel Event

    Here's an implementation of the hack I was talking about:
    VB Code:
    1. Private lastMouseWheel As Date
    2.  
    3. Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
    4.     Me.lastMouseWheel = Date.Now
    5.  
    6.     If Not Me.wheelDetectionTimer.Enabled Then
    7.         'The timer is not enabled so the process is not running.
    8.         'Start desired process here.
    9.         Me.wheelDetectionTimer.Start()
    10.     End If
    11. End Sub
    12.  
    13. Private Sub wheelDetectionTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wheelDetectionTimer.Tick
    14.     If Date.Now.Subtract(Me.lastMouseWheel).TotalSeconds > 0.5R Then
    15.         'The last MouseWheel event was more than half a second ago so assume the wheel is not being scrolled.
    16.         Me.wheelDetectionTimer.Stop()
    17.         'Stop desired process here.
    18.     End If
    19. End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] MouseWheel Event

    Thanks.

    I'll give that a go.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width