Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Forms

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-02-2009, 07:37 AM
cdominguez cdominguez is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: May 2009
Posts: 3
cdominguez is on a distinguished road
Default How to disable the mouse scroll wheel for good (help please)

Hi all,
I just posted this same question to Rural guy in a reply to him after he helped me with another issue I had. I'm putting it here also so others can see as well and may be able to help me.
Like many of you, I want to disable the scroll whell on the mouth when users are working on the form. Now, I have downloaded several fixes online but recently I was able to get one to work until I realized that check boxes were enabling the wheel again as long as the checkbox has the focus, in onther words, if you click on any other field, the wheel is disabled once again.
So here it is, I have the code I downloaded in the "onload" section of the form, when it opens the wheel is disables and that is excellent, as soon as the user clicks on a checkbox the wheel is activated until he'she clicks away from it, can someone help me please, is there additional code that needs to added to what I have to prevent this from hapening. I have no coding experience what so ever but have gotten pretty far with my form and the company likes what I have so far. Here is what I have in the onload section.
**************************************************
Option Compare Database
Option Explicit
Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
Private Declare Function StopMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long, ByVal AccessThreadID As Long, Optional ByVal blIsGlobal As Boolean = False) As Boolean
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 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, GlobalHook)
End Function

'******************** Code Begin ****************
'Code courtesy of
'Terry Kreft & Ken Getz
'
Function CurrentDBDir() As String
Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function
'******************** Code End ****************

Thank you all, thank you!!!!
Reply With Quote
  #2  
Old 06-02-2009, 02:44 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,264
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Did Stephan Lebans' MouseHook work for you?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you disable design view? nkenney Forms 1 04-23-2009 03:08 AM
SQL - Read any good books lately? metaDM Queries 2 03-05-2009 09:46 AM
Auto Scroll in a Form delliott777 Forms 0 05-31-2008 05:02 AM
Mouse Pointer Changes BernardKane Programming 2 06-28-2006 02:55 AM
Creating a *Good* Custom Message Box Jerimiah33 Forms 1 11-09-2005 01:47 PM


All times are GMT -8. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.