Partager via


Pan Gestures (Compact 7)

3/12/2014

A pan gesture (gesture ID GID_PAN) occurs when the user touches the screen with one or two fingers and moves the point(s) of contact. An application may respond to this gesture by moving an object. In the case of a two-finger pan, the application might respond with a zoom in if the fingers move closer together (pinch) or a zoom out if they move farther apart (spread).

For a pan the ptsLocation member of the GESTUREINFO structure provides the location of the finger or fingers. For single touch, ptsLocation is the location of the finger. For multi-touch, ptsLocation is the mid-point of the two fingers, and the upper double word of ullArguments (that is, HIDWORD(ullArguments)) is the distance between them.

Code should check to distinguish a single-touch pan from one that is multi-touch. When the pan is single-touch, one of the following conditions holds:

  • The value HIDWORD(ullArguments), which for the two-finger case provides the distance between the fingers, is zero.
  • The GF_INERTIA flag of dwFlags is non-zero, implying that the pan became a flick gesture. The GF_INERTIA flag is never set for a two-finger pan.

The following example code shows how to check for a single-touch pan instead of a single-touch flick, a two-touch pinch (zoom in), or a stretch (zoom out).

IsPanning(GESTUREINFO* pGi) 
{
    DWORD dwDist = HIDWORD(pGi->ullArguments);

    // return 1 for single-touch pan, otherwise 0
    
    return ((0 == dwDist) && 
        ~(pGi->dwFlags & GF_INERTIA)); 
}

See Also

Concepts

Process Gesture Messages