Share via


Process Gesture Messages (Compact 2013)

3/26/2014

A thread that processes WM_GESTURE event messages will typically have code that switches according to the message ID. The following example code shows what you might see in a Windows procedure that handles the gesture messages.

Warning

The sample code is only a starting point for development. As with any code, you must ensure proper error handling, identify security risks, and thoroughly test it before considering it for production use.

case WM_GESTURE: 
    GESTUREINFO gci;
 
    gci.cbSize = sizeof(GESTUREINFO); 
    hGestureInfo = reinterpret_cast<HGESTUREINFO>(lParam); 
    GetGestureInfo(hGestureInfo, &gci); 
    switch(gci.dwID) 
    {
        case GID_SELECT:
          .
          .
          . 
          break;
        case GID_DOUBLESELECT: 
          .
          .
          . 
          break;

        case GID_HOLD: 
          .
          .
          . 
          break;

        case GID_PAN: 
          .
          .
          . 
          break;

        case GID_SCROLL: 
          .
          .
          . 
          break;

        case GID_DIRECTMANIPULATION: 
          .
          .
          . 
          break;
        }

Pan messages and scroll messages cannot be enabled at the same time as direct manipulation messages for any window. By default, pan and scroll messages are enabled, and direct manipulation messages are disabled. To use direct manipulation, you have to first disable pan and scroll messages by calling the DisableGestures function, and then enable direct manipulation events by calling the EnableGestures function.

Since GWES generates mouse messages WM_LBUTTONUP and WM_LBUTTONMOVE from touch events, there is a danger of double-processing touch events such as move and pan. Applications must avoid this.

There is no corresponding gesture message for WM_LBUTTONDOWN. If your application has to perform an action on button down, you may have to process the WM_LBUTTONDOWN message together with gesture messages.

In This Section

  • Pan Gestures
    Describes how an application detects and handles one- and two-finger pan gestures.
  • Scroll Gestures
    Describes how an application detects and handles scroll gestures.

See Also

Concepts

Gesture Applications