Select to view content in your preferred language

MouseWheel event handler in Map CoClass

1078
4
05-18-2010 03:40 AM
DaveO_Neill
Emerging Contributor
Hi there.

Apologies in advance if I'm missing something really obvious, but I haven't spotted the answer to this in the ArcObjects Library Reference yet ...

Background: I'm maintaining a C++ map display application that makes use of ArcGIS components, version 9.3.1 SP1.  It instantiates a Map object (esriCarto::Map), queries for the IActiveView interface, and calls Activate to pass in the view window client area (and a whole bunch of other properties are also set via various interfaces).  It is then used in the middle of a sequence of drawing operations to render the final display image.

Problem: The WM_MOUSEWHEEL event seems to be picked up in the Map object (or a child object?), and is causing odd behaviour.  What's supposed to happen is that the view window receives this message, then calls a 'zoom' method to trigger appropriate redrawing.  What actually happens is that the message passes through the view window's PreTranslateMessage, then the display area glitches, THEN then view window's OnMouseWheel handler is called to handle the zoom.

By 'glitches', I mean the view window turns white briefly, then the previous image is redisplayed. This did not happen in a previous version of the app that integrated with ArcGIS 9.2, and none of the app's own drawing code is being called while this glitching effect is happening.  It also doesn't happen if the window's zoom function is called via an alternative context menu option.

Having read around the reference info for a while, I suspect that the Map's ScreenDisplay object is responding to the mouse wheel event and doing something we don't want it to do to the view area - I also suspect there's a way of telling it not to, but I can't seem to find it.  I do have a workaround, i.e. to handle the zoom in the view window's PreTranslateMessage, and prevent the message going any further, but that feels like a bit of a hack.

So, can any kind and clever person please point me at a way of telling the Map object to ignore mouse wheel events?

Many thanks,

Dave
0 Kudos
4 Replies
KirkKuykendall
Deactivated User
I also suspect there's a way of telling it not to, but I can't seem to find it


I'd try using Spy++ to figure out what window is blocking the WM_MOUSEWHEEL message then subclassing that window to block the message.  (I suspect it will be the ScreenDisplay's hWnd).
http://support.microsoft.com/kb/815775

When you receive the message you may want to call IScreenDisplayZoom methods.  I thought this is what the map does by default anyway, but maybe not.
0 Kudos
DaveO_Neill
Emerging Contributor
Thanks Kirk, although that also sounds like a bit of a fudge.  If I need to code a workaround, I think the PreTranslateMessage option is the simplest solution, since the app's view window doesn't care about the mouse wheel other than for zooming.

Is there no existing way of calling into the object to change it's behaviour, to make it ignore the mouse wheel?
0 Kudos
KirkKuykendall
Deactivated User
Not sure, might be worth trying these (or combinations thereof):
IViewManager.DelayBackgroundDraw = true
IViewRefresh.ProgressiveDrawing = true
0 Kudos
DaveO_Neill
Emerging Contributor
Thanks, but neither of those options (or combinations) seem to have the desired effect.

Oh well, I guess I'm stuck with using a workaround!

Thanks for the replies.
0 Kudos