Make MshflexGrid support mouse scroll

xiaoxiao2021-03-06  175

Write the following code into the common module

'Support Roller Mouse API --------------------------------- public const gwl_wndproc = (-4) public const wm_command = & H111 Public Const WM_MBUTTONDOWN = & H207 Public Const WM_MBUTTONUP = & H208 Public Const WM_MOUSEWHEEL = & H20A Public Oldwinproc As Long Public 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 Declare Function GetWindowLong Lib "user32" alias "GetWindowLongA" (ByVal hWnd As Long, _ ByVal nIndex As Long) As LongPublic Function FlexScroll (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'support rolling Select Case wheel WMSG Case WM_MOUSE WHEEL Select Case wParam Case -7864320 'scroll down SendKeys "{PGDN}" Case 7864320' roll up SendKeys "{PGUP}" End Select End Select FlexScroll = CallWindowProc (Oldwinproc, hWnd, wMsg, wParam, lParam) End Function 'support Roller mouse API --------------------------------

'Write the following code to the gotfocus event of the table control, the private sub control name _gotfocus () OldwinProc = getWindowlong (me.hwnd, gwl_wndproc) setWindowlong Me.hwnd, GWL_WndProc, Addressof flexscrollend Sub

转载请注明原文地址:https://www.9cbs.com/read-128111.html

New Post(0)