|
-
May 20th, 2002, 10:15 AM
#1
Thread Starter
New Member
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..........
-
May 20th, 2002, 10:22 AM
#2
Frenzied Member
From the ApiWindow code:
VB Code:
ElseIf wMsg = WM_MOUSEWHEEL Then
'\\ x and y are the current cursor pos...
x = APIDispenser.LoWord(lParam)
y = APIDispenser.HiWord(lParam)
Dim lwwParam As Integer
Dim hiwParam As Integer
lwwParam = APIDispenser.LoWord(wParam)
hiwParam = APIDispenser.HiWord(wParam)
If (lwwParam And MK_CONTROL) = lwwParam Then
Shift = Shift Or &H2
End If
If (lwwParam And MK_SHIFT) = lwwParam Then
Shift = Shift Or &H1
End If
If (lwwParam And MK_LBUTTON) = lwwParam Then
Button = Button Or &H1
End If
If (lwwParam And MK_MBUTTON) = lwwParam Then
Button = Button Or &H4
End If
If (lwwParam And MK_RBUTTON) = lwwParam Then
Button = Button Or &H2
End If
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.
-
May 20th, 2002, 10:50 AM
#3
Frenzied Member
*hmm - why isn't that reply showing up?*
-
May 21st, 2002, 01:09 AM
#4
Thread Starter
New Member
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~~~
-
May 21st, 2002, 01:49 AM
#5
Frenzied Member
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
-
May 21st, 2002, 04:20 AM
#6
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|