Disable right-click using Touch and hold Windows 7 Touchscreen device

To see the right-click event, I mean to watch this video .

I am working on an application that adds a zoom button in a Windows Forms application. When the user touches the button, the application must constantly zoom in on the window. This works by observing the click of a mouse button on a button. While the mouse is not working, the timer continues to enlarge the image. This works great while the user finger slides after the initial touch. However, if the user clicks on one place all the time, they will get a small circle of expectation, and then a right-click event.

I added the application code this link to the application:

public bool PreFilterMessage(ref Message m) { // Filter out WM_NCRBUTTONDOWN/UP/DBLCLK if (m.Msg == 0xA4 || m.Msg == 0xA5 || m.Msg == 0xA6) return true; // Filter out WM_RBUTTONDOWN/UP/DBLCLK if (m.Msg == 0x204 || m.Msg == 0x205 || m.Msg == 0x206) return true; return false; } 

This code disables the resulting right-click. However, the circle is still happening and the mousedown event is not happening. Is there a way to make any physical contact count like a mouse down and not start the right-click process?


Change I tried to go to Control Panel β†’ Pen and Touch and turn off the β€œPress and Hold” function for a right click. This turned off the rotation icon, but the mouse still does not appear if the user does not move his finger slightly. I do not understand why the user must write in order to hold the button.

+4
source share
2 answers

The circle shown when touched is a gesture entered in Windows 7 for a right click. It is called Press and hold .

If you want to completely disable this gesture, you need to tell the operating system by calling the SetGestureConfig function when initializing your form. This feature allows you to explicitly indicate which gestures are supported by your control.

0
source

Please try this, it works for me on Windows 10. This is not a global change in the system, press and hold, continue to work in the OS and other programs. It disables pressing and holding only for your window.

.,.

 [DllImport("kernel32.dll", EntryPoint = "GlobalAddAtomA", CharSet=CharSet.Ansi)] static extern UInt16 GlobalAddAtom(string lpString); [DllImport("user32.dll", EntryPoint = "SetPropA", CharSet = CharSet.Ansi)] static extern UInt32 SetProp(IntPtr hWnd, UInt32 lpString, UInt32 hData); 

.,.

 UInt16 atom = GlobalAddAtom("MicrosoftTabletPenServiceProperty"); if (atom != 0) SetProp(this.Handle, (UInt32)atom, 1); 

.,.

0
source

Source: https://habr.com/ru/post/1499478/


All Articles