Evenement scroll sourie

portzic Messages postés 6 Date d'inscription vendredi 20 septembre 2002 Statut Membre Dernière intervention 26 septembre 2002 - 20 sept. 2002 à 23:57
portzic Messages postés 6 Date d'inscription vendredi 20 septembre 2002 Statut Membre Dernière intervention 26 septembre 2002 - 26 sept. 2002 à 07:15
salut a tous
je n'arrive pas à trouver comment utiliser la molette de la sourie pour faire defiler la liste d'un dbcombo ou et dbgrid
merci d'avance

7 réponses

VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
21 sept. 2002 à 18:16
Bonjour ,

'==============inside a MODULE
Option Explicit
'************************************************************
'API
'************************************************************

Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" ( _
ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

'************************************************************
'Constants
'************************************************************

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

'************************************************************
'Variables
'************************************************************

Private hControl As Long
Private lPrevWndProc As Long

'*************************************************************
'WindowProc
'*************************************************************

'zDelta: The value of the high-order word of wParam.
'Indicates the distance that the wheel is rotated, expressed in multiples or
'divisions of WHEEL_DELTA, which is 120. A positive value indicates that the
'wheel was rotated forward, away from the user; a negative value indicates
'that the wheel was rotated backward, toward the user.
Private Function WindowProc(ByVal lWnd As Long, ByVal lMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim fwKeys As Long
Dim zDelta As Long
Dim xPos As Long
Dim yPos As Long

'Test if the message is WM_MOUSEWHEEL
If lMsg = WM_MOUSEWHEEL Then
fwKeys = wParam And 65535
zDelta = wParam / 65536
xPos = lParam And 65535
yPos = lParam / 65536
'Call the Form's Procedure to handle the MouseWheel event
frmAgenda.MouseWheel fwKeys, zDelta, xPos, yPos
End If
'Sends message to previous procedure
'This is VERY IMPORTANT!!!
WindowProc = CallWindowProc(lPrevWndProc, lWnd, lMsg, wParam, lParam)
End Function

'*************************************************************
'Hook
'*************************************************************
Public Sub Hook(ByVal hControl_ As Long)
hControl = hControl_
lPrevWndProc = SetWindowLong(hControl, GWL_WNDPROC, AddressOf WindowProc)
End Sub

'*************************************************************
'UnHook
'*************************************************************
Public Sub UnHook()
Call SetWindowLong(hControl, GWL_WNDPROC, lPrevWndProc)
End Sub

Hook --> Mon Control et at the end UnHook
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
21 sept. 2002 à 18:16
Bonjour ,

'==============inside a MODULE
Option Explicit
'************************************************************
'API
'************************************************************

Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" ( _
ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

'************************************************************
'Constants
'************************************************************

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

'************************************************************
'Variables
'************************************************************

Private hControl As Long
Private lPrevWndProc As Long

'*************************************************************
'WindowProc
'*************************************************************

'zDelta: The value of the high-order word of wParam.
'Indicates the distance that the wheel is rotated, expressed in multiples or
'divisions of WHEEL_DELTA, which is 120. A positive value indicates that the
'wheel was rotated forward, away from the user; a negative value indicates
'that the wheel was rotated backward, toward the user.
Private Function WindowProc(ByVal lWnd As Long, ByVal lMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim fwKeys As Long
Dim zDelta As Long
Dim xPos As Long
Dim yPos As Long

'Test if the message is WM_MOUSEWHEEL
If lMsg = WM_MOUSEWHEEL Then
fwKeys = wParam And 65535
zDelta = wParam / 65536
xPos = lParam And 65535
yPos = lParam / 65536
'Call the Form's Procedure to handle the MouseWheel event
frmAgenda.MouseWheel fwKeys, zDelta, xPos, yPos
End If
'Sends message to previous procedure
'This is VERY IMPORTANT!!!
WindowProc = CallWindowProc(lPrevWndProc, lWnd, lMsg, wParam, lParam)
End Function

'*************************************************************
'Hook
'*************************************************************
Public Sub Hook(ByVal hControl_ As Long)
hControl = hControl_
lPrevWndProc = SetWindowLong(hControl, GWL_WNDPROC, AddressOf WindowProc)
End Sub

'*************************************************************
'UnHook
'*************************************************************
Public Sub UnHook()
Call SetWindowLong(hControl, GWL_WNDPROC, lPrevWndProc)
End Sub

Hook --> Mon Control et at the end UnHook
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
21 sept. 2002 à 18:16
Bonjour ,

'==============inside a MODULE
Option Explicit
'************************************************************
'API
'************************************************************

Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" ( _
ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

'************************************************************
'Constants
'************************************************************

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

'************************************************************
'Variables
'************************************************************

Private hControl As Long
Private lPrevWndProc As Long

'*************************************************************
'WindowProc
'*************************************************************

'zDelta: The value of the high-order word of wParam.
'Indicates the distance that the wheel is rotated, expressed in multiples or
'divisions of WHEEL_DELTA, which is 120. A positive value indicates that the
'wheel was rotated forward, away from the user; a negative value indicates
'that the wheel was rotated backward, toward the user.
Private Function WindowProc(ByVal lWnd As Long, ByVal lMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim fwKeys As Long
Dim zDelta As Long
Dim xPos As Long
Dim yPos As Long

'Test if the message is WM_MOUSEWHEEL
If lMsg = WM_MOUSEWHEEL Then
fwKeys = wParam And 65535
zDelta = wParam / 65536
xPos = lParam And 65535
yPos = lParam / 65536
'Call the Form's Procedure to handle the MouseWheel event
frmAgenda.MouseWheel fwKeys, zDelta, xPos, yPos
End If
'Sends message to previous procedure
'This is VERY IMPORTANT!!!
WindowProc = CallWindowProc(lPrevWndProc, lWnd, lMsg, wParam, lParam)
End Function

'*************************************************************
'Hook
'*************************************************************
Public Sub Hook(ByVal hControl_ As Long)
hControl = hControl_
lPrevWndProc = SetWindowLong(hControl, GWL_WNDPROC, AddressOf WindowProc)
End Sub

'*************************************************************
'UnHook
'*************************************************************
Public Sub UnHook()
Call SetWindowLong(hControl, GWL_WNDPROC, lPrevWndProc)
End Sub

Hook --> Mon Control et at the end UnHook
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
21 sept. 2002 à 18:17
Bonjour ,

'==============inside a MODULE
Option Explicit
'************************************************************
'API
'************************************************************

Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" ( _
ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

'************************************************************
'Constants
'************************************************************

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

'************************************************************
'Variables
'************************************************************

Private hControl As Long
Private lPrevWndProc As Long

'*************************************************************
'WindowProc
'*************************************************************

'zDelta: The value of the high-order word of wParam.
'Indicates the distance that the wheel is rotated, expressed in multiples or
'divisions of WHEEL_DELTA, which is 120. A positive value indicates that the
'wheel was rotated forward, away from the user; a negative value indicates
'that the wheel was rotated backward, toward the user.
Private Function WindowProc(ByVal lWnd As Long, ByVal lMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim fwKeys As Long
Dim zDelta As Long
Dim xPos As Long
Dim yPos As Long

'Test if the message is WM_MOUSEWHEEL
If lMsg = WM_MOUSEWHEEL Then
fwKeys = wParam And 65535
zDelta = wParam / 65536
xPos = lParam And 65535
yPos = lParam / 65536
'Call the Form's Procedure to handle the MouseWheel event
frmAgenda.MouseWheel fwKeys, zDelta, xPos, yPos
End If
'Sends message to previous procedure
'This is VERY IMPORTANT!!!
WindowProc = CallWindowProc(lPrevWndProc, lWnd, lMsg, wParam, lParam)
End Function

'*************************************************************
'Hook
'*************************************************************
Public Sub Hook(ByVal hControl_ As Long)
hControl = hControl_
lPrevWndProc = SetWindowLong(hControl, GWL_WNDPROC, AddressOf WindowProc)
End Sub

'*************************************************************
'UnHook
'*************************************************************
Public Sub UnHook()
Call SetWindowLong(hControl, GWL_WNDPROC, lPrevWndProc)
End Sub

Hook --> Mon Control et at the end UnHook
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
21 sept. 2002 à 18:23
Je sais que j'insiste mais... il y a eu un prob sur le serveur !! bonne chance
0
portzic Messages postés 6 Date d'inscription vendredi 20 septembre 2002 Statut Membre Dernière intervention 26 septembre 2002
26 sept. 2002 à 04:46
salut et merci pour la reponce,
je vais essayer tout de suite
@+ et encore merci
0
portzic Messages postés 6 Date d'inscription vendredi 20 septembre 2002 Statut Membre Dernière intervention 26 septembre 2002
26 sept. 2002 à 07:15
Re: bonjour
au risque d'etre ridicule:
J'ai donc copier le code dans un module mais je ne vois pas comment l'associer à mes differents dbcombo et dbgrid de mon apllication.

rq:quand je compile l'exe, frmagenda(Private Function WindowProc), vb6 me renvoi l'erreur: variable non declarée

merci d'avance
0
Rejoignez-nous