THIS ARTICLE IS NOT COMPLETE. DO NOT MAKE PUBLIC!!
This article looks at the code changes that need to be made to an application to make it zoom properly with Enhance High Resolution Mouse Wheels. It is the third Logitech Code Project article written to help developers implement superior support for enhanced mouse wheels.
In the first article co-authored with Tanvi Shah Handling Enhanced Mouse Wheels in your Application we looked at scrolling issues.
The second article Improving WPF Mouse Wheel Processing written by Roger Vuistiner includes an excellent library that easily adds enhanced mouse wheel support to WPF applications.
Zoom problems with enhanced mouse wheels
Enhanced mouse wheel support was added with Microsoft’s introduction of Vista. For a fixed amount of rotation, an enhanced mouse wheel will generate more wheel events than a standard mouse wheel. With each event, a standard mouse wheel will have a delta value of +/- 120. Enhance mouse wheels will have a smaller value – typically divisible into 120.
Windows Vista and later automatically enables smooth scrolling for any device that supports it. Today, many applications, when used with enhanced mouse wheel, don’t work properly or are not written to support the high resolution feature that takes advantage of the wheel movement’s granularity.
The most common problem with zooming is this.
- Application often ignores the magnitude of the absolute wheel delta value. This causes the application to zoom too quickly.
Other problems include:
- Application does not zoom at all. This occurs if the delta value is not large enough for the application to visibly zoom. The application also fails to accumulate the wheel deltas until the minimum amount needed to zoom is reached.
- If the user goes from zooming in to zooming out (or visa versa), the mouse wheel needs to turn more than one notch. This occurs if the application accumulates the delta (or remainder after zooming) but does not clear it out when zooming is reversed.
- The zooming experience is no smoother than with a standard mouse. This can occur when the application only zooms when the accumulated delta reaches a magnitude of WHEEL_DELTA (defined in winuser.h as 120).
How to test enhanced mouse wheel zoom
Note: Since Enhanced Wheel support is not available on XP, use Windows Vista and above.
- How to test your application with real hardware that has enhanced mouse wheel.
You will need a mouse with Enhanced Scroll Wheel capabilities with the appropriate drivers. You may find it necessary to contact the manufacturer to obtain drivers or directions as to how to turn ON this capability. To see if it is turned on, you’ll want to run Spy++ or similar Message snooping software to capture the WM_MOUSEWHEEL messages. Use the scroll wheel to zoom your application. What you want to see are multiple messages for a small turn of the mouse wheel and each message with an absolute delta value of less than 120 (In the below example, we see a zDelta of -15).
- How to test your application using the emulator provided in this article?
If you do not have an enhanced wheel mouse, use the Enhanced Scroll Wheel Emulator included. This application emulates an enhanced wheel by sending smaller wheel deltas to your application. So you can still test your application by running the emulator application (HiResScrollWheel.exe) and create your own Hi-Res WM_MOUSEWHEEL messages.
Launching HiResScrollWheel.exe and setting the parameters as follows emulates a Hi-Res mouse with 8 events per click and a delta of 15.
If your application behaves well, the zooming behavior will be smoother with the Enhanced Mouse wheel. It also zooms the same amount as with a regular mouse wheel.
Adding enhanced wheel zoom support to a Silverlight application
The first application I will add enhanced mouse wheel zoom support to is DeepZoomSample.
Blocks of code should be set as style "Formatted"
Remember to set the Language of your code snippet using the
Use the "var" button to to wrap Variable or class names in
<code> tags like
Points of Interest
Did you learn anything interesting/fun/annoying while writing
the code? Did you do anything particularly clever or wild or zany?
Keep a running update of any changes or improvements you've