Link to home
Start Free TrialLog in
Avatar of JosP
JosP

asked on

Can't eat WM_MOUSEWHEEL message

Hi,

I'm subclassing the hWnd of a control on a form. It's actually the ScreenDisplay-object of ArcMap: I'm developing an application in ArcGIS using ArcObjects an VB6. But never mind those specifics, it's just like a picturebox than can scroll.

I want to prevent the scrolling using the wheel on the mouse. So I tried eating the WM_MOUSEWHEEL message using this code:

Public Const WM_MOUSEWHEEL = &H20A

Public Function WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
'this is my message handler
    Select Case iMsg
        Case WM_MOUSEWHEEL
            WindowProc = False
            Exit Function
        Case Else
    End Select
    WindowProc = CallWindowProc(ProcOld, hwnd, iMsg, wParam, lParam)
End Function


ProcOld = SetWindowLong(mpScreenDisplay.hwnd, GWL_WNDPROC, AddressOf WindowProc)

Call SetWindowLong(mpScreenDisplay.hwnd, GWL_WNDPROC, ProcOld)
               
I've used Spy++ to see if the WM_MOUSEWHEEL is sent, and that is the case. But the code just steps over the case statement.

Any ideas?

JosP
ASKER CERTIFIED SOLUTION
Avatar of aeklund
aeklund

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aeklund
aeklund

Also, when testing, try to click the control first, then try the mousewheel.
Avatar of JosP

ASKER

Thanks for your answer, I did indeed hook the wrong object. It turned out that after I hooked the object it was destroyed and recreated for a new situation.

JosP
Your welcome.. glad to assist.

I have to ask, whey did you grade my answer as a "B"?  If it was not satisfactory to you I wish you would have posted that fact so that I would of had a chance to respond and perhaps supply your with an "A" grade in your mind.

Please elaborate.

Allen
Avatar of JosP

ASKER

Maybe you deserve an "A", I guess you were a victim of my frustation. Next time I'll be more conscious...

JosP
Thanks for the follow-up...