By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,096 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,096 IT Pros & Developers. It's quick & easy.

How to capture WHEEL_DELTA

P: 9
I cant seem to figure out how to determine if the mouse wheel is scrolled up or down after the WM_MOUSEWHEEL event has occured. Microsoft states the wParam value will contain the WHEEL_DELTA value in the high-order word. How do I get the wParam value? Please help me, I have threads going in 4 vb coding forums including microsoft's msdn, and I cant seem to find an answer.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/mouseinputreference/mouseinputmessages/wm_mousewheel.asp

****I am using JournalRecordProc

Public Function JournalRecordProc(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

**** and doing this

CopyMemory tEVENTMSG, ByVal lParam, Len(tEVENTMSG)

**** where tEVENTMSG is structed as follows

Public Type EVENTMSG
message As Long
paramL As Long
paramH As Long
time As Long
hwnd As Long
End Type


paramL and paramH do not contain the DWORD value to retrieve WHEEL_DELTA
Apr 3 '07 #1
Share this Question
Share on Google+
6 Replies


P: 9
Bumping.....Please help.........
Apr 3 '07 #2

P: 9
Figured it out on my own. Thanks anyway.

If anyone is interested in the answer comment in this thread and I'll tell you. Otherwise.....your on your own.
Apr 3 '07 #3

Expert 5K+
P: 8,434
Figured it out on my own. Thanks anyway.

If anyone is interested in the answer comment in this thread and I'll tell you. Otherwise.....your on your own.
Hi.

Sorry you weren't able to source your answer here. Ordinarily I'd have expected to see a better response, but of course there are no guarantees in life.

I for one would certainly be interested to see the answer, and would also like to have it available here for anyone who faces a similar problem in the future.
Apr 4 '07 #4

P: 9
I had a single form named form1

I subclassed the form with this hook..........
Expand|Select|Wrap|Line Numbers
  1. lngOldProc = SetWindowLong(form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
and this procedure.............

Expand|Select|Wrap|Line Numbers
  1. Public Function WindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  2.     Select Case msg
  3.         Case WM_MOUSEWHEEL
  4.             WheelDelta = HiWord(wParam)
  5.         Case Else
  6.             WindowProc = CallWindowProc(lngOldProc, hwnd, msg, wParam, lParam)
  7.     End Select
  8.  
  9. End Function
with this function ...............
Expand|Select|Wrap|Line Numbers
  1. Public Function HiWord(ByVal DWord As Long) As Integer
  2.     HiWord = (DWord And &HFFFF0000) \ &H10000
  3. End Function

And this worked fine for the form1.hwnd I declared in the hook. However when changing the hwnd value to the value I capture from eventmsg structure in JournalRecordProc to an active window created from a different process the hook doesnt work..........

According to microsoft in re: SetWindowLong

An application can subclass a system class, but should not subclass a window class created by another process.
So this kinda leaves me back at square one. Brings to mind a question about windows programming. What is the difference between a subclass, and a window class? Is a subclass like a control on the active window? Should I be using the hwnd of a control from the window created under a different process rather than the hwnd of the window itself?
Apr 4 '07 #5

P: 9
I didnt want to do this but it looks like I gotta...

WH_MOUSE_LL hook will provide the MSLLHOOKSTRUCT where I can extract the DELTA value from any window system wide. Better than trying to subclass, which you can not do on windows under a different process.
Apr 4 '07 #6

Expert 5K+
P: 8,434
I didnt want to do this but it looks like I gotta...

WH_MOUSE_LL hook will provide the MSLLHOOKSTRUCT where I can extract the DELTA value from any window system wide. Better than trying to subclass, which you can not do on windows under a different process.
Don't know about the others here, but this is mostly over my head. Perhaps you'd have been better off hitting somewhere like the Windows forum for this sort of thing. Or one of the languages that doesn't tend to insulate the developer quite so much from the OS.

I know you can do just about anything in VB, but in my experience the majority of programmers tend not to. Sadly.

Anyway, thanks for the info.
Apr 4 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.