Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Other topics FAQ


No Mouse Wheel Scrolling by katiekat
Posted: 27 Jun 01

I found this answer in another forum, and I have seen many threads concerning it. I thought I should post this for everyone's benefit.  I didn't write this, so don't thank me, thank the guy who posted it.  

Here is the answer I found in case anyone else was wondering...
From: Feras Mash <fmash@matrixsoft.com>
Subject: How to Disable (ignore) the Mouse Wheel..

So here's the code we used to ignore the Mouse Wheel on any form:
This is added to a Module:
Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Declare Function RegisterWindowMessage& Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String)
Public Const GWL_WNDPROC = -4
Public IsHooked As Boolean
Public lpPrevWndProc As Long
Public gHW As Long
Public Sub Hook()

If IsHooked Then
'MsgBox "Don't hook it twice without " & _
' "unhooking, or you will be unable to unhook it."
IsHooked = True
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf WindowProc)
IsHooked = True
End If
End Sub
Public Sub Unhook()

Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
IsHooked = False
End Sub
Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long

If uMsg = GetMouseWheelMsg Then
' Debug.Print "Message: "; hw, uMsg, wParam, lParam
WindowProc = 0
WindowProc = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End If
End Function
Public Function GetMouseWheelMsg() As Long
GetMouseWheelMsg = 522 'this works for Win98/2000, otherwise use

End Function
This is added to each Form:
Sub Form_Load()
'Store handle to this form's window
gHW = Me.hwnd
If IsHooked Then
Call Unhook
End If

'Call procedure to begin capturing messages for this window
Call Hook

End Sub
Private Sub Form_Unload(Cancel As Integer)
'Call procedure to stop intercepting the messages for this window
Call Unhook
End Sub
Hope it Helps everyone!!
F. Mash
MatrixSoft, Inc.

Just a note:
I forgot to add this.  It seems to lock up your form on the first viewing of it after you add the on load/unload events, but it doesn't seem to affect form useage after that initial tweak.

Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close