?
Solved

Can't eat WM_MOUSEWHEEL message

Posted on 2003-03-07
6
Medium Priority
?
695 Views
Last Modified: 2012-05-04
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
Comment
Question by:JosP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
aeklund earned 1500 total points
ID: 8089217
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
 
LVL 10

Expert Comment

by:aeklund
ID: 8089231
Also, when testing, try to click the control first, then try the mousewheel.
0
 

Author Comment

by:JosP
ID: 8101556
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:aeklund
ID: 8103406
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
 

Author Comment

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

JosP
0
 
LVL 10

Expert Comment

by:aeklund
ID: 8111572
Thanks for the follow-up...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question