CloseGestureInfoHandle Function

Closes resources associated with a gesture information handle.

Syntax

BOOL WINAPI CloseGestureInfoHandle(
  HGESTUREINFO hGestureInfo
);

Parameter

  • hGestureInfo
    The gesture information handle.

Rückgabewert

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, use the GetLastError function.

Hinweise

If an application processes a WM_GESTURE message, it is responsible for closing the handle using this function. Failure to do so may result in process memory leaks.

If the message is passed to DefWindowProc, or is forwarded using one of the PostMessage or SendMessage classes of API functions, the handle is transferred with the message and need not be closed by the application.

Beispiele

The following code shows a handler that closes the GESTUREINFO handle if the gesture has been handled.

  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);
    }
  }

Anforderungen

Mindestens unterstützter Client

Windows 7

Mindestens unterstützter Server

Windows Server 2008 R2

Header

Winuser.h (include Windows.h)

Bibliothek

User32.lib

DLL

User32.dll

Siehe auch

Functions

Programming Guide for Gestures