cs_darunia
Messages postés354Date d'inscriptionmercredi 18 décembre 2002StatutMembreDernière intervention24 mars 2011
-
25 mars 2003 à 13:38
cs_Biname
Messages postés2Date d'inscriptionjeudi 18 mars 2004StatutMembreDernière intervention27 octobre 2004
-
27 oct. 2004 à 14:10
Salut,
Est-ce que quelqu'un sait comment désactiver la roulette dans un formulaire access ?
Ca me fausse tout alors si quelqu'un peut m'aider ...
cs_Biname
Messages postés2Date d'inscriptionjeudi 18 mars 2004StatutMembreDernière intervention27 octobre 2004 27 oct. 2004 à 14:10
Bonjour,
Vous pourriez peut-etre essayer ceci.....
Je vous souhaite bonne chance pour votre réalisation
Créez un module standard que vous appelez basSubClassWindow et vous copiez le code ci-dessous:
Option Compare Database
Option Explicit
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public 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
Public Const GWL_WNDPROC = -4
Public Const WM_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public CMouse As CMouseWheel
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MouseWheel
CMouse.FireMouseWheel
If CMouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
*************************************************
Créez un module de classe que vous appelez CMouseWheel et vous copiez le code ci-dessous:
Option Compare Database
Option Explicit
Private frm As Access.Form
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
Public Property Set Form(frmIn As Access.Form)
Set frm = frmIn
End Property
Public Property Get MouseWheelCancel() As Integer
MouseWheelCancel = intCancel
End Property
Public Sub SubClassHookForm()
lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
AddressOf WindowProc)
Set CMouse = Me
End Sub
Public Sub SubClassUnHookForm()
Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Sub FireMouseWheel()
RaiseEvent MouseWheel(intCancel)
End Sub
Dans le code de votre formulaire, incluez le code ci-dessous soit par copie soit en insérant les lignes dans les sub déjà présentes:
Option Compare Database
Option Explicit
Private WithEvents clsMouseWheel As CMouseWheel
Private Sub Form_Load()
If Me.DefaultView = 0 Then
Set clsMouseWheel = New CMouseWheel
Set clsMouseWheel.Form = Me
clsMouseWheel.SubClassHookForm
End If
End Sub
Private Sub Form_Close()
If Me.DefaultView = 0 Then
clsMouseWheel.SubClassUnHookForm
Set clsMouseWheel.Form = Nothing
Set clsMouseWheel = Nothing
End If
End Sub
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
Cancel = True
End Sub
Attention: N'utilisez pas le formulaire à ce moment-là sinon Access va se bloquer. Quittez VBA, Quittez Access, relancez votre base et exécutez le formulaire.