Results 1 to 3 of 3

Thread: mouse wheel

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2020
    Posts
    2

    mouse wheel

    Hi, this is a very interesting forum, I looked in the forum, I have not found a discussion on mouse scroll wheel picturebox, only zoom picture box. who can help me. I attach the fileCassa-Prova.zipCassa-Prova.zipCassa-Prova.zip

  2. #2
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,051

    Re: mouse wheel

    mouse wheel involves subclassing

    I use this:

    to start it (only when compiled)
    Code:
    IDE = CBool(App.LogMode = 0)
    If IDE = False Then
       hOldWheelProc = GetWindowLong(form1.hwnd, GWL_WNDPROC)
       SetWindowLong form1.hwnd, GWL_WNDPROC, AddressOf MWheelProc
    End If
    This is the code that will check the mousewheel, change HEREUP and HEREDOWN with your code
    Code:
    Private Function MWheelProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        If wMsg = WM_MOUSEWHEEL Then
            If Sgn(wParam) = 1 Then HEREUP Else HEREDOWN
        Else
            MWheelProc = CallWindowProc(hOldWheelProc, hwnd, wMsg, wParam, lParam)
        End If
    End Function
    and this when end of program, very important
    Code:
    If hOldWheelProc > 0 Then SetWindowLong form1.hwnd, GWL_WNDPROC, hOldWheelProc
    important:
    hOldWheelProc need to be Public variable
    and form1.hwnd need to be changed by the main forms name

    Code:
    Private Const GWL_WNDPROC = (-4)
    Private Const WM_MOUSEWHEEL = &H20A
    Private 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
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Last edited by baka; May 17th, 2020 at 01:03 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2020
    Posts
    2

    Re: mouse wheel


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width