mousehooks

jedder18

Just Livin the Dream!
Local time
Today, 11:04
Joined
Mar 28, 2012
Messages
135
Converted a really old MDB to an ACCDB.
error message on command button is

Sorry cannot find the Mousehook.dll file

This is the Module....

Private Declare Function StartMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long) As Boolean
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
' Instance returned from LoadLibrary call
Private hLib As Long

Public Function MouseWheelON() As Boolean
MouseWheelON = StartMouseWheel(Application.hWndAccessApp)
If hLib <> 0 Then
hLib = FreeLibrary(hLib)
End If
End Function
Public Function MouseWheelOFF(Optional NoSubFormScroll As Boolean = False, Optional GlobalHook As Boolean = False) As Boolean
Dim s As String
Dim blRet As Boolean
Dim AccessThreadID As Long
On Error Resume Next
' Our error string
s = "Sorry...cannot find the MouseHook.dll file" & vbCrLf
s = s & "Please copy the MouseHook.dll file to your Windows System folder or into the same folder as this Access MDB."
' OK Try to load the DLL assuming it is in the Window System folder
hLib = LoadLibrary("MouseHook.dll")
If hLib = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLib = LoadLibrary(CurrentDBDir() & "MouseHook.dll")
If hLib = 0 Then
MsgBox s, vbOKOnly, "MISSING MOUSEHOOK.dll FILE"
MouseWheelOFF = False
Exit Function
End If
End If
' Get the ID for this thread
AccessThreadID = GetCurrentThreadId()
' Call our MouseHook function in the MouseHook dll.
' Please not the Optional GlobalHook BOOLEAN parameter
' Several developers asked for the MouseHook to be able to work with
' multiple instances of Access. In order to accomodate this request I
' have modified the function to allow the caller to
' specify a thread specific(this current instance of Access only) or
' a global(all applications) MouseWheel Hook.
' Only use the GlobalHook if you will be running multiple instances of Access!
MouseWheelOFF = StopMouseWheel(Application.hWndAccessApp, AccessThreadID, NoSubFormScroll, GlobalHook)
End Function




Help...clueless here
 
Looks like Stephan Leban's old MouseWheelOnOff code which required a separate .dll file that you stored in the Windows/System folder, or the same folder as the db file.

In newer versions of Access (A2007 and later), custom code like that is no longer required because the mouse wheel scrolling is disabled by default in form view. If you want to change the default behavior, have a look here.
 
Thanks so much for the response.
Found the .dll file in the folder(wasn't told it was there)
Anywho...all worked out.
Learn something new all the time.
 

Users who are viewing this thread

Back
Top Bottom