[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

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
0
JosP
Asked:
JosP
  • 4
  • 2
1 Solution
 
aeklundCommented:
Try adding some debug statements to see if the event is being captured:

Case WM_MOUSEWHEEL
  Debug.Print "WM_MOUSEWHEEL"
  WindowProc = False
  Exit Function


If you never see it captured, then perhaps you have the hook on the wrong window...
0
 
aeklundCommented:
Also, when testing, try to click the control first, then try the mousewheel.
0
 
JosPAuthor Commented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
aeklundCommented:
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
0
 
JosPAuthor Commented:
Maybe you deserve an "A", I guess you were a victim of my frustation. Next time I'll be more conscious...

JosP
0
 
aeklundCommented:
Thanks for the follow-up...
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now