WM_GESTURE message
Passes information about a gesture.
Parameters
-
wParam
-
Provides information identifying the gesture command and gesture-specific argument values. This information is the same information passed in the ullArguments member of the GESTUREINFO structure.
-
lParam
-
Provides a handle to information identifying the gesture command and gesture-specific argument values. This information is retrieved by calling GetGestureInfo.
Return value
If an application processes this message, it should return 0.
If the application does not process the message, it must call DefWindowProc. Not doing so will cause the application to leak memory because the touch input handle will not be closed and associated process memory will not be freed.
Remarks
The following table lists the supported gesture commands.
Gesture ID | Value (dwID) | Description |
---|---|---|
GID_BEGIN | 1 | Indicates a generic gesture is beginning. |
GID_END | 2 | Indicates a generic gesture end. |
GID_ZOOM | 3 | Indicates zoom start, zoom move, or zoom stop. The first GID_ZOOM command message begins a zoom but does not cause any zooming. The second GID_ZOOM command triggers a zoom relative to the state contained in the first GID_ZOOM. |
GID_PAN | 4 | Indicates pan move or pan start. The first GID_PAN command indicates a pan start but does not perform any panning. With the second GID_PAN command message, the application will begin panning. |
GID_ROTATE | 5 | Indicates rotate move or rotate start. The first GID_ROTATE command message indicates a rotate move or rotate start but will not rotate. The second GID_ROTATE command message will trigger a rotation operation relative to state contained in the first GID_ROTATE. |
GID_TWOFINGERTAP | 6 | Indicates two-finger tap gesture. |
GID_PRESSANDTAP | 7 | Indicates the press and tap gesture. |
Note
In order to enable legacy support, messages with the GID_BEGIN and GID_END gesture commands need to be forwarded using DefWindowProc.
The following table indicates the gesture arguments passed in the lParam and wParam parameters.
Gesture ID | Gesture | ullArgument | ptsLocation in GestureInfo structure |
---|---|---|---|
GID_ZOOM | Zoom In/Out | Indicates the distance between the two points. | Indicates the center of the zoom. |
GID_PAN | Pan | Indicates the distance between the two points. | Indicates the current position of the pan. |
GID_ROTATE | Rotate (pivot) | Indicates the angle of rotation if the GF_BEGIN flag is set. Otherwise, this is the angle change since the rotation has started. This is signed to indicate the direction of the rotation. Use the GID_ROTATE_ANGLE_FROM_ARGUMENT and GID_ROTATE_ANGLE_TO_ARGUMENT macros to get and set the angle value. | This indicates the center of the rotation which is the stationary point that the target object is rotated around. |
GID_TWOFINGERTAP | Two-finger Tap | Indicates the distance between the two fingers. | Indicates the center of the two fingers. |
GID_PRESSANDTAP | Press and Tap | Indicates the delta between the first finger and the second finger. This value is stored in the lower 32 bits of the ullArgument in a POINT structure. | Indicates the position that the first finger comes down on. |
Note
All distances and positions are provided in physical screen coordinates.
Note
The dwID and ullArgument parameters should only be considered to be accompanying the GID_* commands and should not be altered by applications.
Examples
The following code illustrates how to obtain gesture-specific information associated with this message.
Note
You should always forward unhandled messages to DefWindowProc and should close the gesture input handle for messages that you do handle with a call to CloseGestureInfoHandle. In this example, the default gesture handler behavior will be suppressed because the TOUCHINPUT handle is closed in each of the gesture cases. If you removed the cases in the above code for unhandled messages, the default gesture handler would process the messages by getting forwarded to DefWindowProc in the default case.
LRESULT DecodeGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
// 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);
BOOL bHandled = FALSE;
if (bResult){
// now interpret the gesture
switch (gi.dwID){
case GID_ZOOM:
// Code for zooming goes here
bHandled = TRUE;
break;
case GID_PAN:
// Code for panning goes here
bHandled = TRUE;
break;
case GID_ROTATE:
// Code for rotation goes here
bHandled = TRUE;
break;
case GID_TWOFINGERTAP:
// Code for two-finger tap goes here
bHandled = TRUE;
break;
case GID_PRESSANDTAP:
// Code for roll over goes here
bHandled = TRUE;
break;
default:
// A gesture was not recognized
break;
}
}else{
DWORD dwErr = GetLastError();
if (dwErr > 0){
//MessageBoxW(hWnd, L"Error!", L"Could not retrieve a GESTUREINFO structure.", MB_OK);
}
}
if (bHandled){
return 0;
}else{
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows 7 [desktop apps only] |
Minimum supported server |
Windows Server 2008 R2 [desktop apps only] |
Header |
|