public static extern bool SetGestureConfig( IntPtr hwnd, // window for which configuration is specified uint dwReserved, // reserved, must be 0 uint cIDs, // count of GESTURECONFIG structures GESTURECONFIG[] pGestureConfig, // array of GESTURECONFIG structures, dwIDs will be processed in the // order specified and repeated occurances will overwrite previous ones uint cbSize); // sizeof(GESTURECONFIG)
protected override void WndProc(ref Message m) { if (_gestureConfigSize == 0) { SetupStructSizes(); } bool handled; switch (m.Msg) { case WM_GESTURENOTIFY: { GESTURECONFIG gc = new GESTURECONFIG(); gc.dwID = GID_ZOOM; gc.dwWant = GC_ALLGESTURES; gc.dwBlock = 0; bool bResult = SetGestureConfig(Handle, 0, 1, ref gc, _gestureConfigSize); if (!bResult) { throw new Exception("Error in execution of SetGestureConfig"); } handled = true; break; } case WM_GESTURE: { handled = DecodeGesture(ref m); break; } default: { handled = false; break; } } base.WndProc(ref m); if (handled) { try { m.Result = new IntPtr(1); } catch (Exception excep) { Debug.Print("Could not allocate result ptr"); Debug.Print(excep.ToString()); } } }
public void GetGestureConfigTest() { var array = new GESTURECONFIG[] { new GESTURECONFIG(GID.GID_ZOOM), new GESTURECONFIG(GID.GID_ROTATE), new GESTURECONFIG(GID.GID_PAN) }; var aLen = (uint)array.Length; var b = GetGestureConfig(FindWindow(null, null), 0, 0, ref aLen, array, (uint)Marshal.SizeOf(typeof(GESTURECONFIG))); if (!b) { Win32Error.ThrowLastError(); } Assert.That(b, Is.True); Assert.That(aLen, Is.GreaterThan(0)); for (var i = 0; i < aLen; i++) { TestContext.WriteLine($"{array[i].dwID} = {array[i].dwWant} / {array[i].dwBlock}"); } }
protected override void SubclassCreated(Subclass subclass) { GESTURECONFIG gc = new GESTURECONFIG(); gc.dwID = 0; // gesture ID gc.dwWant = Const.GC_ALLGESTURES; // settings related to gesture ID that are to be turned on gc.dwBlock = 0; // settings related to gesture ID that are to be // We must p/invoke into user32 [winuser.h] bool bResult = User32.SetGestureConfig( subclass.HWnd, // window for which configuration is specified 0, // reserved, must be 0 1, // count of GESTURECONFIG structures ref gc, // array of GESTURECONFIG structures, dwIDs will be processed in the order specified // and repeated occurances will overwrite previous ones FGestureConfigSize // sizeof(GESTURECONFIG) ); base.SubclassCreated(subclass); }
private static extern bool SetGestureConfig(IntPtr hWnd, int dwReserved, int cIDs, ref GESTURECONFIG pGestureConfig, int cbSize);
protected override void WndProc(ref Message m) { bool handled = false; switch (m.Msg) { case WM_GESTURENOTIFY: { // This is the right place to define the list of gestures // that this application will support. By populating // GESTURECONFIG structure and calling SetGestureConfig // function. We can choose gestures that we want to // handle in our application. In this app we decide to // handle all gestures. GESTURECONFIG gc = new GESTURECONFIG { dwID = 0, // gesture ID dwWant = GC_ALLGESTURES, // settings related to gesture // ID that are to be turned on dwBlock = 0 // settings related to gesture ID that are }; // to be // We must p/invoke into user32 [winuser.h] bool bResult = SetGestureConfig( Handle, // window for which configuration is specified 0, // reserved, must be 0 1, // count of GESTURECONFIG structures ref gc, // array of GESTURECONFIG structures, dwIDs // will be processed in the order specified // and repeated occurances will overwrite // previous ones _gestureConfigSize // sizeof(GESTURECONFIG) ); if (!bResult) { throw new Exception("Error in execution of SetGestureConfig"); } } handled = true; break; case WM_GESTURE: // The gesture processing code is implemented in // the DecodeGesture method handled = DecodeGesture(ref m); break; default: handled = false; break; } // Filter message back up to parents. base.WndProc(ref m); if (handled) { // Acknowledge event if handled. try { m.Result = new System.IntPtr(1); } catch (Exception) { } } }
public static extern bool SetGestureConfig(IntPtr hWnd, int dwReserved, int cIDs, ref GESTURECONFIG[] pGestureConfig, int cbSize);
protected override void WndProc(ref Message m) { bool handled; handled = false; switch (m.Msg) { case WM_GESTURENOTIFY: { // This is the right place to define the list of gestures // that this application will support. By populating // GESTURECONFIG structure and calling SetGestureConfig // function. We can choose gestures that we want to // handle in our application. In this app we decide to // handle all gestures. GESTURECONFIG gc = new GESTURECONFIG(); gc.dwID = 0; // gesture ID gc.dwWant = GC_ALLGESTURES; // settings related to gesture // ID that are to be turned on gc.dwBlock = 0; // settings related to gesture ID that are // to be // We must p/invoke into user32 [winuser.h] bool bResult = SetGestureConfig( Handle, // window for which configuration is specified 0, // reserved, must be 0 1, // count of GESTURECONFIG structures ref gc, // array of GESTURECONFIG structures, dwIDs // will be processed in the order specified // and repeated occurances will overwrite // previous ones _gestureConfigSize // sizeof(GESTURECONFIG) ); if (!bResult) { throw new Exception("Error in execution of SetGestureConfig"); } } handled = true; break; case WM_GESTURE: // The gesture processing code is implemented in // the DecodeGesture method handled = DecodeGesture(ref m); break; default: handled = false; break; } // Filter message back up to parents. base.WndProc(ref m); if (handled) { // Acknowledge event if handled. try { m.Result = new System.IntPtr(1); } catch (Exception excep) { Debug.Print("Could not allocate result ptr"); Debug.Print(excep.ToString()); } } }