Vertical swipe simulating mouse events sent to the wrong control in a Windows Forms application on a Windows 10 tablet

I am trying to run a Windows Forms application on a Windows 10 tablet (Dell Venue 8 Pro). In general, Windows translates touch events into obvious mappings of mouse events. However, he does something weird with vertical clicks.

My application has a custom control (obtained directly from Control with a call to SetStyle(ControlStyles.Selectable..., true) in its constructor), which shows the graphics displayed by Direct3D. The control interprets the sequences MouseDown β†’ MouseMove β†’ MouseUp as requests to rotate the representation of the lookat position. This works fine on the desktop, but it breaks on the tablet: vertical checks on my user control are somehow caught by Windows and passed to the nearest DataGridView , where they are interpreted as table scroll requests. DataGridView and my control are not siblings in the same container; they are at completely different levels of the management hierarchy. Here is a screenshot:

Screenshot of various interpretations of vertical and horizontal scrolls

I did some debugging to prove to myself that no mouse events fall under my control during vertical scrolling. A few streams to the right when I raise my finger, but there is nothing during the vertical scroll.

The problem is that my code (in the event handlers) simply does not run, because no input comes into my control.

What happens here, and is there any way that I can tell Windows not to send vertical swipe events that happen due to my control to a completely unrelated control?

Change I must add that I call Focus() all over the place in my code to make sure my control is focused when the mouse is over it. I put it in OnMouseMove , OnMouseDown and pretty much every other mouse event.

Change I created a small Visual Studio 2010 solution demonstrating this problem. This is too much code to reproduce inline here, but it is easy to understand. Build it, install it on your Windows 10 tablet, and try turning it vertically to the right-most control. Note that instead of this control receiving a bunch of mouse events, the DataGridView fires a Scroll .

Refresh . I explicitly checked if my control is focused when the DataGridView receives a Scroll event. If I answer Focus() to my control in response to MouseMove , etc., As indicated above, my control receives focus and holds it while scrolling vertically while the DataGridView.Scroll arrow. In the DataGridView.Scroll event handler, I printed out whether my control is centered, and it is. So this is not a focus issue for the DataGridView ; this is a DataGridView issue of handling a swipe designed for my control, even when my control is focused.

Note If I set dataGridView.ScrollBars to ScrollBars.None , mouse event for swipe will go to my control. I fiddled with ugly hacks that hide scrollbars every time my control focuses and shows them every time the DataGridView focuses. But they are all ugly hacks with unpleasant side effects.

+8
c # windows-10 scroll winforms touch
source share
1 answer

How to exchange touch events on your own, and not wait for the correct implementation of Microsoft. link

+1
source share

All Articles