Thema Datum  Von Nutzer Rating
Antwort
Rot Scroll in Listbox 64bit Version scrollt nur nach oben
27.01.2022 08:11:47 Siggi
NotSolved
27.01.2022 09:41:11 volti
NotSolved
27.01.2022 10:46:35 volti
NotSolved
27.01.2022 11:00:09 Siggi
NotSolved
27.01.2022 11:10:20 Siggi
NotSolved
27.01.2022 11:26:39 volti
NotSolved
27.01.2022 19:33:55 Gast85208
NotSolved
27.01.2022 19:20:41 Gast85208
NotSolved
31.01.2022 08:18:32 Siggi
NotSolved
31.01.2022 10:22:57 volti
NotSolved
31.01.2022 10:52:25 Siggi
NotSolved

Ansicht des Beitrags:
Von:
Siggi
Datum:
27.01.2022 08:11:47
Views:
687
Rating: Antwort:
  Ja
Thema:
Scroll in Listbox 64bit Version scrollt nur nach oben

Hallo zusammen, 

ich habe das Problem, dass meine Scrollfunktion einer Listbox bei der 64Bit version nur nach oben scrollt.

Kann mir da jemand weiter helfen?

 

Danke im Voraus

Siggi

 

Anbei mein Code:

 

 

 

Option Explicit

Private Type POINTAPI
     X As LongPtr
     Y As LongPtr
End Type

Private Type MOUSEHOOKSTRUCT
     Pt As POINTAPI
     hwnd As LongPtr
     wHitTestCode As LongPtr
     dwExtraInfo As LongPtr
End Type

Private Declare PtrSafe Function FindWindow Lib "user32" _
                     Alias "FindWindowA" ( _
                             ByVal lpClassName As String, _
                             ByVal lpWindowName As String) As LongPtr

Private Declare PtrSafe Function GetWindowLong Lib "user32.dll" _
                     Alias "GetWindowLongA" ( _
                             ByVal hwnd As LongPtr, _
                             ByVal nIndex As LongPtr) As LongPtr

Private Declare PtrSafe Function SetWindowsHookEx Lib "user32" _
                     Alias "SetWindowsHookExA" ( _
                             ByVal idHook As LongPtr, _
                             ByVal lpfn As LongPtr, _
                             ByVal hmod As LongPtr, _
                             ByVal dwThreadId As LongPtr) As LongPtr

Private Declare PtrSafe Function CallNextHookEx Lib "user32" ( _
                             ByVal hHook As LongPtr, _
                             ByVal nCode As LongPtr, _
                             ByVal wParam As LongPtr, _
                             lParam As Any) As LongPtr

Private Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" ( _
                             ByVal hHook As LongPtr) As LongPtr

Private Declare PtrSafe Function PostMessage Lib "user32.dll" _
                     Alias "PostMessageA" ( _
                             ByVal hwnd As LongPtr, _
                             ByVal wMsg As LongPtr, _
                             ByVal wParam As LongPtr, _
                             ByVal lParam As LongPtr) As LongPtr

Private Declare PtrSafe Function WindowFromPoint Lib "user32" ( _
                             ByVal xPoint As LongPtr, _
                             ByVal yPoint As LongPtr) As LongPtr

Private Declare PtrSafe Function GetCursorPos Lib "user32.dll" ( _
                             ByRef lpPoint As POINTAPI) As LongPtr

Private Const WH_MOUSE_LL As LongPtr = 14
Private Const WM_MOUSEWHEEL As LongPtr = &H20A
Private Const HC_ACTION As LongPtr = 0
Private Const GWL_HINSTANCE As LongPtr = (-6)

Private Const WM_KEYDOWN As LongPtr = &H100
Private Const WM_KEYUP As LongPtr = &H101
Private Const VK_UP As LongPtr = &H26
Private Const VK_DOWN As LongPtr = &H28
Private Const WM_LBUTTONDOWN As LongPtr = &H201

Private mLngMouseHook As LongPtr
Private mListBoxHwnd As LongPtr
Private mbHook As Boolean

Sub HookListBoxScroll()
Dim lngAppInst As LongPtr
Dim hwndUnderCursor As LongPtr
Dim tPT As POINTAPI
        GetCursorPos tPT
        hwndUnderCursor = WindowFromPoint(tPT.X, tPT.Y)
        If mListBoxHwnd <> hwndUnderCursor Then
             UnhookListBoxScroll
             mListBoxHwnd = hwndUnderCursor
                lngAppInst = GetWindowLong(mListBoxHwnd, GWL_HINSTANCE)
                PostMessage mListBoxHwnd, WM_LBUTTONDOWN, 0&, 0&
             If Not mbHook Then
                     mLngMouseHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, lngAppInst, 0)
                     mbHook = mLngMouseHook <> 0
             End If
     End If
End Sub

Sub UnhookListBoxScroll()
     If mbHook Then
             UnhookWindowsHookEx mLngMouseHook
             mLngMouseHook = 0
             mListBoxHwnd = 0
             mbHook = False
     End If
End Sub

Private Function MouseProc( _
             ByVal nCode As LongPtr, ByVal wParam As LongPtr, _
             ByRef lParam As MOUSEHOOKSTRUCT) As LongPtr
        On Error GoTo errH 'Resume Next
        If (nCode = HC_ACTION) Then
             If WindowFromPoint(lParam.Pt.X, lParam.Pt.Y) = mListBoxHwnd Then
                     If wParam = WM_MOUSEWHEEL Then
                             MouseProc = True
                             If lParam.hwnd > 0 Then
                                     PostMessage mListBoxHwnd, WM_KEYDOWN, VK_UP, 0
                             Else
                                     PostMessage mListBoxHwnd, WM_KEYDOWN, VK_DOWN, 0
                             End If
                             PostMessage mListBoxHwnd, WM_KEYUP, VK_UP, 0
                             Exit Function
                     End If
             Else
                     UnhookListBoxScroll
             End If
     End If
        MouseProc = CallNextHookEx( _
                             mLngMouseHook, nCode, wParam, ByVal lParam)
     Exit Function
errH:
        UnhookListBoxScroll
End Function


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot Scroll in Listbox 64bit Version scrollt nur nach oben
27.01.2022 08:11:47 Siggi
NotSolved
27.01.2022 09:41:11 volti
NotSolved
27.01.2022 10:46:35 volti
NotSolved
27.01.2022 11:00:09 Siggi
NotSolved
27.01.2022 11:10:20 Siggi
NotSolved
27.01.2022 11:26:39 volti
NotSolved
27.01.2022 19:33:55 Gast85208
NotSolved
27.01.2022 19:20:41 Gast85208
NotSolved
31.01.2022 08:18:32 Siggi
NotSolved
31.01.2022 10:22:57 volti
NotSolved
31.01.2022 10:52:25 Siggi
NotSolved