Security problems with mousehook.dll

J

Jeff Hunt

I have a question about disabling the mouse wheel. I have used the
MOUSEHOOK.DLL procedure from Stephen Lebans in the past and it does work (I
have the file in the same folder and the module in the database) but I am
looking for an alternate way. I recently changed companies and my new one
has a security monitor that pops up every time a form turns the mouse wheel
off (it says that MSACCESS.EXE is trying to log all keys via MOUSEHOOK.DLL).
I can disable it, but it comes back every time you reboot, therefore it is
not a practical solution for my users. I don’t care about being able to
scroll on text boxes or anything else, I just need to prevent the wheel from
changing which record you are on in a form bound to a table. Is there any
other way to prevent this besides Stephen’s code?
 
J

Jeff Hunt

If there is not a way to block scrolling, is there at least a way to detect
it? That way if they scroll to a different record w/o using the nav buttons
I provided, I can force them back to the correct record or at least warn them
of what they did. Thanks.
 
D

Douglas J. Steele

Not really.

The form's Current event fires each time you change records. I suppose you
coould have a form-level variable that you set to True when your navigation
buttons are used, and have the Current event check the value of that
variable. If it's True, everything's okay (remember to set the variable back
to False!). If it's False, the user didn't use the navigation buttons.
However, you'll need to figure out which record they came from.
 
J

Jeff Hunt

I noticed that event shortly after posting and considered using it. The
problem there is that even if you have a message in the On Mouse Wheel, it
still changes the records. I'm looking into a way to force the user back to
the record they were on before. Douglas's suggestion gave me some ideas on
doing that... we'll see if they work. Thanks for the suggestion!

Hoardling1 via AccessMonster.com said:
I don't know about the code for the scrolling mouse. If you are using Access
2003 or later, I believe the forms property event On Mouse Wheel event you
can add a message box stating to the user they moved off the record.
Hopefully this helps.

Jeff said:
If there is not a way to block scrolling, is there at least a way to detect
it? That way if they scroll to a different record w/o using the nav buttons
I provided, I can force them back to the correct record or at least warn them
of what they did. Thanks.
I have a question about disabling the mouse wheel. I have used the
MOUSEHOOK.DLL procedure from Stephen Lebans in the past and it does work (I
[quoted text clipped - 7 lines]
changing which record you are on in a form bound to a table. Is there any
other way to prevent this besides Stephen’s code?
 
J

Jeff Hunt

With just a little tweaking, I got your suggestion to work. I already had a
textbox on the form that was updating to show the current record number each
time one of my nav buttons was pushed, so that allowed me to know which
record they were supposed to be on. Still need to test a few things around
this but it appears to be working. Here are the pertinent parts of my code
for doing this.

Option Compare Database
Private blnSafeMove As Boolean
'-----------------------------------------------------------
Private Sub Form_Load()
blnSafeMove = True
End Sub
'-----------------------------------------------------------
Private Sub Form_Current()
If blnSafeMove = False Then
If Me.txtCurrentRecord <> Form.CurrentRecord Then
DoCmd.GoToRecord , , acGoTo, Me.txtCurrentRecord
End If
End If
End Sub
'-----------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
blnSafeMove = False
End Sub
'-----------------------------------------------------------
Private Sub cmdPrevious_Click()
blnSafeMove = True
DoCmd.GoToRecord , , acPrevious
Me.txtCurrentRecord = Form.CurrentRecord
End Sub
'-----------------------------------------------------------
Private Sub cmdNext_Click()
blnSafeMove = True
DoCmd.GoToRecord , , acNext
Me.txtCurrentRecord = Form.CurrentRecord
End Sub
'-----------------------------------------------------------

The net effect is that when you scroll, you may see a flicker in one of the
bound fields (because it is moving the record before it moves back), but it
always ends up staying on the correct record.

Thanks so much for the help on this.

....jeff...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top