Results 1 to 4 of 4

Thread: Anyone knows how to MOUSEEVENTF_WHEEL?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    Anyone knows how to use MOUSEEVENTF_WHEEL?
    Mako Shark
    Great White

  2. #2
    Guest
    Isn't it whenever it returns a positive value it is scrolling up and whenever it returns a negative value it is scrolling down?

    It's probably not, but I'm sure that's how I used it.

  3. #3
    Guest
    If you want events to trigger when the wheel is rotated, Subclass the WM_MOUSEWHEEL message.

    Add the following to a Module
    Code:
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    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
    Const GWL_WNDPROC = (-4)
    Const WM_MOUSEWHEEL = &H20A
    
    Global WndProcOld As Long
    
    Private Function HiWord(ByVal LongVal As Long) As Integer
        If LongVal = 0 Then
            HiWord = 0
            Exit Function
        End If
        HiWord = LongVal \ &H10000 And &HFFFF&
    End Function
    
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        On Error Resume Next
        If wMsg = WM_MOUSEWHEEL Then
            If HiWord(wParam) < 0 Then
                Form1.Picture1.Top = Form1.Picture1.Top + 120
            Else
                Form1.Picture1.Top = Form1.Picture1.Top - 120
            End If
        End If
      
        WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
        
    End Function
    
    Sub SubClassWnd(hwnd As Long)
        WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub
    
    Sub UnSubclassWnd(hwnd As Long)
        SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
        WndProcOld& = 0
    End Sub
    Add the following to a Form with a PictureBox.
    Code:
    Private Sub Form_Load()
        SubClassWnd hwnd
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        UnSubclassWnd hwnd
    End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247

    Thanks for your help again Megatron.

    Mako Shark
    Great White

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