Disable Mouse Wheel in Access 2002 (XP)

tim1234

Registered User.
Local time
Today, 14:03
Joined
Nov 19, 2002
Messages
38
I keep seeing people saying that in Access XP there is a way to turn off the mouse wheel. How is that done? I see the new option for "On Mouse Wheel", but what code or macro will disable it? Any help would be greatly appreciated.
 
I don't know if there is an easier way to do this in XP, but a guy from my office passed this code on to me:

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
Else
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
Else
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
'RegisterWindowMessage("MSWHEEL_ROLLMSG")

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
 
Disable Mouse Wheel In XP

Worked Great Thanks alot!
 
IT WORKS!!!!!

woooohooo!!!!!!!!!!!

thanks so much lloyd - worked like a charm!

seems like its the only post that actually helpped

even the microsoft page didnt work, but that bit of code you posted did!
 
Awesome

Thank You So MUCH
I have been going crazy trying to get this to work and your code work so well!

For a complete n00b like me you're a freakin' hero.

This is by far the best and most elegant solution to the Microsoft Access Disable Scroll Wheel problem I've found in hours of searching. :D
 
I must be doing something wrong. . .

I get Compile Error: Invalid use of Me keyword
when I run the module.

Sub Form_Load()
'Store handle to this form's window
gHW = Me.hwnd
If IsHooked Then
Call Unhook
End If

I am a completely green when it comes to Access and MVB. I've surprised myself in creating the db and form. Now there are just a couple tweaks I want done and disabling the Wheel is one of them.

My db is for troubleshooting outlet issues. I have a list of outlets and their various configurations. Users NEVER add or change any info. They select the outlet from a combo box and view the information. The problem is that you can move the wheel and change the outlet information but the combo box does not reflect the change; it continues to show the initially selected outlet.

Maybe an easier solution is to figure out how to make the combo box information follow the wheel. . . Any ideas there?

By the way I'm using Access2000 on an XP machine. . .
 
Last edited:
I have implemented that method on three of my form recently and it seems to work brillantly and was exactly what I needed. Unfotunately, I have started to experience some problem related to that code (I think): my mouse started to be entirely disable and frozen and I ended up not being able to interact with the database like if it was frozen.
I was wondering if any body that has used this code had experienced similar behaviour and find a solution to avoid it.
I must admit that I don't understand a lot about this code and it might sound a bit cheeky to ask for help so i give my apologies in advance for any inconvenience.
 
I used this code

I used this code and have not experienced any problems. I also couldn't tell you anything about this code except for it did not cause me any problems. Good luck
 
Hi
I'm a total Access n00b but I managed to get this code working on a vicious old beast of a database that we use at work, which an exceptionally beardy gentleman developed (it does amazing things). But that scroll wheel thing has been doing my head in for 4 years.

If it's of use to anyone, my problem getting it to work was because of names clashing - there was already something buried deep in the main form's code:

Private Sub Form_Load()
DoCmd.Maximize
End Sub

I'm not a coder but I figured out that I could combine the two bits of code so I deleted the one further down the page, and inserted the maximise bit into the relevant section:

Private Sub Form_Load()
DoCmd.Maximize
Set clsMouseWheel = New MouseWheel.CMouseWheel
Set clsMouseWheel.Form = Me
clsMouseWheel.SubClassHookForm
End Sub

And dagnabbit it worked.

Many thanks to the originator of this bit of code - I wish I had found this out 4 years ago...
cheers
Planckton
 

Users who are viewing this thread

Back
Top Bottom