En este grupo En todos

Foro de Access



VBA Access 2003 y/o 2007

Alejandro
Abogacia universidad de moron
Escrito por Alejandro Izura Duvigneau
el 16/09/2010
Buen día gente del foro Mi pregunta es: Existe alguna posibilidad de anular la ruedita del scroll del mouse con codificación en VBA e introducirlo en algun módulo mio ya diseñado con otras cosas? Mi idea venía porque ya uso la anulación de la tecla del Shift y el Ctrol + Pause. A ver si hay algo similar. Gracias por la atención Alejandro
fayad
Escrito por fayad
el 16/09/2010
Creas un modulo, llamandolo: mod Mouse Hook
'Pega este codigo.
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 Stop Mouse Wheel Lib " Mouse Hook" _
(ByVal hWnd As Long, ByVal AccessThreadID As Long, _
Optional ByVal bNoSubform Scroll As Boolean = False, Optional ByVal blIsGlobal As Boolean = False) As Boolean
Private Declare Function Start Mouse Wheel Lib " Mouse Hook" _
(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 Mouse WheelOFF(Optional NoSubForm Scroll 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 Mouse Hook. Dll file" & vbCrLf
s = s & "Please copy the Mouse Hook. 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(" Mouse Hook. 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() & " Mouse Hook. Dll")
If hLib = 0 Then
MsgBox s, vbOKOnly, "MISSING MOUSE HOOK. Dll FILE"
Mouse WheelOFF = False
Exit Function
End If
End If
' Get the ID for this thread
AccessThreadID = GetCurrentThreadId()
Mouse WheelOFF = Stop Mouse Wheel(Application. HWndAccessApp, AccessThreadID, NoSubForm Scroll , GlobalHook)
End Function
'******************** Code Begin ****************
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 ****************
Yo lo utilizaba en el evento de abrir el formulario me bloqueara el mouse .... ´pero lo puedes utilizar en otro evento.
Private Sub Form_Open(Cancel As Integer)
Dim blRet As Boolean
' Desabilitar la rueada del mouse
BlRet = Mouse WheelOFF(False)
DoCmd. Maximize
End Sub
Necesitas bajar un archivo. DDL llamado Mouse Hook. Dll


otra opción; mirate este Enlace

salu2
Alejandro Izura Duvigneau
Abogacia universidad de moron
Escrito por Alejandro Izura Duvigneau
el 18/09/2010

Muchisimas gracias Fayad! Es justo lo que necesitaba.
Muy buena la programacion.
Saludos
Alejandro