Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trap mouse side scroll events

Status
Not open for further replies.

cjelec

Programmer
Jan 5, 2007
491
GB
Hi,

Does anyone know how to trap the side scroll events when the user clicks the scroll left/right buttons on their mouse.

I've tried the MouseWheel event but that only supports vertical scrolling. I've also looked at the MouseDown event, but that doesn't fire when the scroll buttons are pressed, so I tried overriding the PreProcessMessage function to see if there are any messages that fire on the side scrolling but there doesn't seem to be any...

Can anyone help with this?

Thanks

Chris
 
To update from my post above,

I found that the WndProc sob does pick up the side scroll buttons and that the Msg for the button press is &H20E (526).

But this event only fire's when the side scroll buttons are pressed and I couldn't find a button release Msg, so I'm still stuck with trying to get a smooth scrolling effect.

Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    
    If m.Msg = &H20E Then
        Dim wp As Long = Long.Parse(m.WParam)
        If wp < 0 Then
            'Scrolling to the left
        Else
            'Scrolling to the right
        End If

        Exit Sub
    End If

    MyBase.WndProc(m)
End Sub

So, can some one help me with finding a way to trap the side scroll button press (held down) events, because the code above only runs when the user clicks the buttons...

Thanks again

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top