WM_GESTURE

4/8/2010

The WM_GESTURE message is sent to a window procedure to indicate that a gesture has occurred or, in the case of a pan, is in progress.

WM_GESTURE messages can be forwarded synchronously from a WndProc using the SendMessage(), SendMessageTimeout() or SendNotifyMessage () APIs.

Note

WM_GESTURE messages cannot be forwarded from a WindowProc using PostMessage or PostThreadMessage.

The window procedure can call TKGetGestureInfo to determine the state of the gesture.

A window receives this message through its WindowProc function.

Syntax

WM_GESTURE
    WPARAM wParam
    LPARAM lParam

Parameters

  • wParam
    Contains the ID of the gesture command.
  • lParam
    Contains the HGESTUREINFO handle of the gesture command.

Return Value

If the application processes the gesture, it returns a non–zero value. If the application does not process the gesture, it should pass it to DefWindowProc and the return value would be the value returned by DefWindowProc.

Remarks

Based on the gesture ID, you should decide whether the application should handle the gesture itself, or whether it should pass the gesture to DefWindowProc. GID_BEGIN and GID_END should always be passed to DefWindowProc. If the application processes the gesture, it does not pass the message to the default window procedure.

The following code sample shows how the gesture can be handled based on its ID.

GESTUREINFO gi;
memset(&gi, 0, sizeof(gi));
gi.cbSize = sizeof(GESTUREINFO);
if (GetGestureInfo((HGESTUREINFO)lParam, &gi))
{
    // Handle gesture indicated by wParam or gi.dwID
}
else
{
    // Error handling
}

The HGESTUREINFO handle is created just before the WindowProc is called. It is destroyed by returning from the window procedure. Note that an application cannot save the HGESTUREINFO handle for later use. The lParam value of WM_GESTURE is meaningless outside of the window procedure, as the HGESTUREINFO handle does not become valid until DispatchMessage delivers the message to the window procedure. Therefore, the following code sample will not work properly.

while (GetMessage(&msg, NULL, 0, 0))
{
    if (msg.msg == WM_GESTURE)
    {
        GetGestureInfo(msg.lParam,...)
    }
}

An unhandled WM_GESTURE message passed to DefWindowProc will be propagated to the parent window. When forwarding gesture messages between windows, avoid sending messages from parent to child windows in order to prevent closed loops from occurring.

Requirements

Windows Mobile Windows Mobile 6.5 and later