Results 1 to 6 of 6

Thread: Detect mouse's wheeling infomaiotn??

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    8

    Detect mouse's wheeling infomaiotn??

    vbsic code:
    --------------------------------------------------------------------------------
    Public Function MouseHookProc(ByVal nCode As Long, ByVal wParam As Long, mhs As MOUSEHOOKSTRUCT) As Long
    'Public Function MouseHookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim strBuffer As String
    Dim lngBufferLen As Long
    Dim strClassName As String
    Dim lngResult As Long
    If (nCode >= 0 And wParam = WM_MOUSEWHEEL) Then
    'Preinitialize string
    strBuffer = Space(255)
    'lngBufferLen = Len(strBuffer)

    'This is the string that holds the class name that we are looking for
    strClassName = "Internet Explorer_Server"
    'Debug.Print strClassName

    'Get the classname for the Window that has been clicked, making sure something is returned
    'If the function returns 0, it has failed
    lngResult = GetClassName(mhs.hwnd, strBuffer, Len(strBuffer))
    'Debug.Print Left$(strBuffer, lngResult)

    If lngResult > 0 Then
    'Check to see if the class of the window we clicked on is the same as above
    If Left$(strBuffer, lngResult) = strClassName Then
    'Value is the same. Squash the command
    MouseHookProc = 1
    'Invoke our Custom Context Menu.
    'frmMain.PopupMenu frmMain.mnuPopup
    Exit Function
    End If
    End If
    End If

    MouseHookProc = CallNextHookEx(gLngMouseHook, nCode, wParam, mhs)
    End Function

    ------------------------------------------------------------------------------------
    now I can detect the WM_MOUSEWHEEL...
    But I couldn't know some informaiton of mouse wheeling
    for example,the rotation of mouse wheel...
    how could i do?
    thanx..........

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    From the ApiWindow code:

    VB Code:
    1. ElseIf wMsg = WM_MOUSEWHEEL Then
    2.         '\\ x and y are the current cursor pos...
    3.         x = APIDispenser.LoWord(lParam)
    4.         y = APIDispenser.HiWord(lParam)
    5.         Dim lwwParam As Integer
    6.         Dim hiwParam As Integer
    7.         lwwParam = APIDispenser.LoWord(wParam)
    8.         hiwParam = APIDispenser.HiWord(wParam)
    9.         If (lwwParam And MK_CONTROL) = lwwParam Then
    10.             Shift = Shift Or &H2
    11.         End If
    12.         If (lwwParam And MK_SHIFT) = lwwParam Then
    13.             Shift = Shift Or &H1
    14.         End If
    15.         If (lwwParam And MK_LBUTTON) = lwwParam Then
    16.             Button = Button Or &H1
    17.         End If
    18.         If (lwwParam And MK_MBUTTON) = lwwParam Then
    19.             Button = Button Or &H4
    20.         End If
    21.         If (lwwParam And MK_RBUTTON) = lwwParam Then
    22.             Button = Button Or &H2
    23.         End If
    24.         RaiseEvent MouseWheelMove(hiwParam, Button, Shift, x, y)
    i.e. the HIWORD of wParam is the scroll amount (positive number is up, negative number is down), the LOWORD of wParam is the state of the mouse buttons, and lParam holds the current x,y position of the cursor as with every mouse message.

    Hope this helps,
    Duncan
    Last edited by MerrionComputin; May 20th, 2002 at 10:28 AM.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  3. #3
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    *hmm - why isn't that reply showing up?*
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    8
    Thanx your post ......
    But I didn't want to use ApiWindow...
    I only detect the movement of mouse........
    I hook mouse message...
    I could detect the movement of mouse now but i couldn't detect
    some information of the movement of mouse...
    For Example,the rotation value of mouse wheel...
    plz help me~~~

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    I was suggesting you use the snippet above, not the entire class....
    i.e. the HIWORD of wParam is the scroll amount (positive number is up, negative number is down), the LOWORD of wParam is the state of the mouse buttons, and lParam holds the current x,y position of the cursor as with every mouse message.
    This lParam and wParam are in the MSG part of the MOUSEHOOKSTRUCT.

    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    8
    I get mousedata in the MSG part of the MOUSEHOOKSTRUCTEX.
    thanx yor help...

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