DOCX

Multitouch Gestures with MFC - Native

By Jason Perry,2014-09-21 13:54
8 views 0
Multitouch Gestures with MFC - Native

Hands-On Lab

    Multitouch Gestures with MFC - Native

Lab version: 1.0.0

    Last updated: 9/21/2011

Multitouch Gesture HOL (C++)

CONTENTS

    OVERVIEW ............................................................................................................................................. 3

    EXERCISE 1: BUILD A MULTITOUCH GESTURE APPLICATION ......................................................... 6

    Task 1 Create the MFC application using the Application Wizard ................................................... 6

    Task 2 Test the Existence and Readiness of Multitouch Hardware ............................................... 12

    Task 3 Add the Drawing Object Source and Header Files to the Project, and Draw the Rectangle 14

    Task 4 Touch Now! ...................................................................................................................... 17

    Task 5 There Is a Bug!.................................................................................................................. 20

    SUMMARY ............................................................................................................................................ 22

    2

Multitouch Gesture HOL (C++)

Overview

    Windows 7 gives users the ability to manage applications with the touch of their fingers, without the need of a stylus. This new gesture capability allows multiple input events to occur 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 2010

    ; Windows 7

    ; A multitouch hardware device ;

Introduction

    To create a Multitouch driven application you should design your application’s user interface with touch

    capabilities in mind. For example, the controls you use should be relatively large to support a finger rather than a mouse or stylus. Beyond that you have 3 different approaches you can consider:

    1. Rely upon touch capabilities already a part of existing Win32 controls. For example, Win32

    controls already support some touch capabilities such as scrolling without any extra coding in

    your application. Go ahead and try to scroll the document you are reading using your fingers.

    2. Read and handle low-level touch events and create your own sophisticated touch handling

    interface. This is the approach used by complex multiple sliders that users can operate

    simultaneously or by applications like “Piano” or MS Paint. For example, run MS Paint, select a

    drawing tool from the gallery and draw with four of your fingers (if the hardware permits):

    3

Multitouch Gesture HOL (C++)

    3. Use the new Multitouch gestures to get touch events to your applications to support custom

    actions like zoom, rotate, and translate without the need to read and manipulate raw touch

    events. This is the approach used in this Hands-On Lab.

About the Multitouch Gesture Demo

    The Multitouch Gesture demo presents a simple window containing a rectangle that can be modified using Multitouch gestures. Inside the Sources\MFC_GestureDemoSource folder, you can find a Starter

    folder that contains files you will need during this lab and a finished version of the lab which 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 one or 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

    4

    Multitouch Gesture HOL (C++)

separate contact points.

Rotate

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

Zoom

    Touch two fingers and move them farther apart or closer together.

Two Finger Tap

    5

Multitouch Gesture HOL (C++)

    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.

Exercise 1: Build a Multitouch Gesture

    Application

    Task 1 Create the MFC application using the Application Wizard

    1. Start Visual Studio 2010.

    2. Create a new MFC application project with the name TouchGestureDemo and press OK.

    6

Multitouch Gesture HOL (C++)

    3. In the Application Type dialog of the MFC Application Wizard, select Single Document. To keep

    the application simple, select (or deselect) the options in the various dialogs of the MFC

    Application Wizard based on the screenshots below and then press Next > after each dialog.

    7

Multitouch Gesture HOL (C++)

8

Multitouch Gesture HOL (C++)

9

Multitouch Gesture HOL (C++)

10

Report this document

For any questions or suggestions please email
cust-service@docsford.com