Share via


Overview

Windows 7 gives users the ability to manage applications with the touch of their fingers, using no intermediate device. This expands the stylus-based capabilities of tablet PCs. Unlike other pointing devices, this new capability allows multiple input events at the same time from different pointing locations, and it enables complex scenarios, such as managing applications with ten fingers or with multiple simultaneous users. However, to pull this off, we have to adapt our application's user interface and behavior to support this new input model.

Objectives

In this Hands-On Lab, you will learn how to manage gesture events, including:

  • Understanding the implications of manipulating an object with gesture events
  • Checking for multitouch hardware existence and readiness
  • Extracting information from the gesture Windows Message

System Requirements

You must have the following items to complete this lab:

  • Microsoft Visual Studio 2008 SP1
  • Windows 7
  • The Windows 7 SDK
  • A multitouch hardware device

Introduction

To create a multitouch driven application you can choose one of three approaches, the Good, the Better, or the Best.

The “Good” approach is the easiest among the three. You should design your application user interface with touch ability in mind. Use large and clean Win32 based controls that make a natural interface for a better user experience. Touch abilities such as scrolling come from the Win32 controls. There is no need for extra work. For example, try to scroll the document that you are reading now with your fingers! This is the “Good” approach.

The “Best” approach is to read the low-level touch events as the input to the application. Applications like “Piano” or complex controls like multiple-sliders that users can operate simultaneously are good examples. Run MS Paint, select a drawing tool from the gallery and draw with four of your fingers (if the hardware permits):

In this Hands-On Lab, you will use the “Better” approach. The “Better” approach is the easiest way to get touch events to your application for custom actions like zoom, rotate, and translate without the need to read and manipulate raw touch events. Enter Multitouch Gestures!

About the Multitouch Gesture Application

The Multitouch Gesture application presents a simple window containing a rectangle. In the HOL folder, you can find a project for each task of the lab. The Starter folder contains files that you will need during the lab. A finished version of the lab is located in the Final folder.

This application responds to multitouch gesture input by interacting with a painted rectangle. The rectangle responds to the following gestures:

Translate

To translate the image, place two fingers in the application window and drag in the direction you want. Make sure to leave a little space between the two fingers so that the touch interface sees them as separate contact points.

Rotate

Touch the rectangle with two fingers and turn fingers in a circle.

Zoom

Touch two fingers and move them closer or farther apart.

Two Finger Tap

Tap once with both fingers to toggle diagonal lines on or off within the red rectangle.

Finger Roll

Press and hold one finger, then tap with the other and then remove the first one to change the color of the rectangle.