Option Explicit
Implements ISubclass
Private Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Const SPI_GETWHEELSCROLLLINES As Long = 104
Private Const WM_MOUSEWHEEL As Long = &H20A
Private Const WHEEL_DELTA As Long = 120
Private mGrid As DataGrid
Public Sub Start(ByVal g As DataGrid)
If Not mGrid Is Nothing Then SubClasser.RemoveSubclassHook mGrid.hWnd
Set mGrid = g
SubClasser.AddSubclassHook g.hWnd, Me, DoNotTransfer
End Sub
Public Sub Stopp()
If Not mGrid Is Nothing Then
SubClasser.RemoveSubclassHook mGrid.hWnd
Set mGrid = Nothing
End If
End Sub
Private Function GetNumberOfLinesToScroll() As Long
SystemParametersInfo SPI_GETWHEELSCROLLLINES, 0, GetNumberOfLinesToScroll, 0
End Function
Private Function ISubclass_Callback(ByVal hWnd As Long, uMsg As Long, wParam As Long, lParam As Long, ByVal PrevProc As Long) As Long
Static Delta As Long
If uMsg = WM_MOUSEWHEEL Then
Delta = Delta + wParam / &H10000
If Abs(Delta) >= WHEEL_DELTA Then
mGrid.Scroll 0, -GetNumberOfLinesToScroll * (Delta \ WHEEL_DELTA)
Delta = Delta Mod WHEEL_DELTA
End If
ISubclass_Callback = 0
Else
ISubclass_Callback = SubClasser.CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
End If
End Function
Нет, надо сабклассить...Типа: IF указатель мыши нах-ся над DataGrid AND происходит ScrollUp Or ScrollDawn Then событие; (событие тоже, что и при VScrollBar)?
DemonTol писал(а):P.S. Как говорится пинок в нужном направлении
Private Function ISubclass_Callback...
If uMsg = WM_MOUSEWHEEL Then...
GSerg писал(а):Где лежит subclasser, сами знаете.
farbox писал(а):да , теперь без ошибок , но скролл по прежнему не работает ......
что делать то ?
If uMsg = WM_MOUSEWHEEL Then...
GSerg писал(а):Andrey Fedorov, твоя мысль мне совершенно не ясна.
Option Explicit
Implements SSubTimer6.ISubclass
Private Const WM_MouseWheel = &H20A
Private m_hWnd As Long
Public Event MouseWheel(RollUp As Boolean)
Public Sub Create(hWnd As Long)
If hWnd Then m_hWnd = hWnd: AttachMessage Me, m_hWnd, WM_MouseWheel
End Sub
Private Property Let ISubclass_MsgResponse(ByVal RHS As SSubTimer6.EMsgResponse)
'
End Property
Private Property Get ISubclass_MsgResponse() As SSubTimer6.EMsgResponse
ISubclass_MsgResponse = emrPostProcess
End Property
Private Function ISubclass_WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case iMsg
Case WM_MouseWheel: RaiseEvent MouseWheel(wParam > 0)
End Select
End Function
Private Sub Class_Terminate()
If m_hWnd Then DetachMessage Me, m_hWnd, WM_MouseWheel: m_hWnd = 0
End Sub
Set m_CMW = New CMouseWheels
m_CMW.Create MyPictureBox.hWnd
Сейчас этот форум просматривают: Yandex-бот и гости: 30