Interpreting the WM_GESTURE message

In the Tablet / Touch forums, there has been some confusion about interpreting the WM_GESTURE message, the GID_PRESSANDTAP gesture, specifically.  The gist of getting to the message is:

  • Turn the lParam into a GestureInfo structure.
  • Grab the POINT value from the ptsLocation member
  • Convert the lower 32 bits of the ullArgument member into a POINT structure

The following code shows how to get a GESTUREINFO from the LPARAM


// Create a structure to populate and retrieve the extra
// message info.
GESTUREINFO gi;
double d;
ZeroMemory(&gi, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL bResult = GetGestureInfo((HGESTUREINFO)lParam, &gi);
// Create a structure to populate and retrieve the extra
// message info.
GESTUREINFO gi;
ZeroMemory(&gi, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL bResult = GetGestureInfo((HGESTUREINFO)lParam, &gi);

The following code shows how the first touch point (x/y) and delta values (x/y) can be interpreted from the ullArguments / ptsLocation values from the GESTUREINFO structure.

case GID_PRESSANDTAP:
// Code for pressandtap goes here
pt = _localizePoint(gi.ptsLocation);

temp = gi.ullArguments;

if (temp > 0){

Log << "touch x: ["<< pt.x << "]\n";
Log << "touch y: ["<< pt.y << "]\n";
Log << endl;

pt = MAKEPOINTS(temp);
POINTSTOPOINT(delta, pt);

Log << "delta x: ["<< pt.x << "]\n";
Log << "delta y: ["<< pt.y << "]\n";
Log << endl;

}
bHandled = TRUE;
break;

This code uses a utility function, _localizePoint, which simply calls ScreenToClient on a POINT struct.


POINTS
_localizePoint(const POINTS& pt)
{
POINT point;
point.x = pt.x;
point.y = pt.y;

BOOL bResult = ScreenToClient(m_hwnd, &point);

POINTS pts;
pts.x = (SHORT)point.x;
pts.y = (SHORT)point.y;

return pts;
}


// Create a structure to populate and retrieve the extra

Advertisement
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.