Click here to Skip to main content
11,642,855 members (75,265 online)
Click here to Skip to main content

Improve Zooming with Enhanced Mouse Wheels

, 20 Oct 2011 CPOL 19.7K 2.3K 27
Rate this:
Please Sign up or sign in to vote.
How to give your users a better zooming experience with High Resolution Mouse Wheels
This is an old version of the currently published article.

THIS ARTICLE IS NOT COMPLETE. DO NOT MAKE PUBLIC!!

 

Introduction

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).
spy.png
  • 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.
EMULATOR.png
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.

deepzoom.png

Blocks of code should be set as style "Formatted" like this:  

			//
			// Any source code blocks look like this
			//
		

Remember to set the Language of your code snippet using the Language dropdown.   

Use the "var" button to to wrap Variable or class names in <code> tags like this.  

Points of Interest

Did you learn anything interesting/fun/annoying while writing the code? Did you do anything particularly clever or wild or zany?

History

Keep a running update of any changes or improvements you've made here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Stephen H Davis
Software Developer (Senior) Logitech Corporation
United States United States
Stephen lives in Fremont, CA with his wife and daughter and has programmed in C and C++ for a very long time.

You may also be interested in...

Comments and Discussions


Discussions posted for the Published version of this article. Posting a message here will take you to the publicly available article in order to continue your conversation in public.
 
GeneralMy vote of 5 Pin
manoj kumar choubey20-Feb-12 22:01
membermanoj kumar choubey20-Feb-12 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 20 Oct 2011
Article Copyright 2011 by Stephen H Davis
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid