dual/multi monitor with touchscreen
Asked Answered
D

1

11

Pretend I have 2 monitors. Primary display is just a normal PC desktop monitor, the other other one is a touchscreen. When I load a program (WinForm, WPF, ...), it will load on the primary monitor.

Question: if I replace the program to the touchscreen, how can I know if the current screen/display/monitor is a touchscreen or has touch enabled?

In other words, how can I detect the current screen/display/monitor and its settings?

So far i worked with the Screen class (Windows.Forms), Tablet Class (Windows.Input) and with DLLImport of User32.dll (GetSystemMetrics()). None of them or a combination of them works.

I want something to find like: Monitor.Current.IsTouch or Display.CurrentDisplay.TouchEnabled

Damarisdamarra answered 17/9, 2012 at 9:25 Comment(7)
And what if application window is somewhere between both monitors!? I would personally make program to work with both touch and mouse the same way. Explained here xonoxlabs.com/161/mouse-over-touch-screensBricole
Dear Saeid, program works wih mouse, touch and stylus. the reason i post this, is that i want to add some extra functionallity but only if the monitor/display is capable to use touch. you can say it like: if(CapableTouch){DoExtraTouchStuff();} else{DoExtraOtherStuff();}Damarisdamarra
Yes I know you point and I really hope someone can give a nice answer to your question, because I have the same question as well! that’s why I up voted and some other guys have up voted. But again, can you point to a situation that can be handled differently by mouse and touch?Bricole
the handler is connected on an (UI) element. this element can be at monitor 1 or 2. knowing in which monitor it is, u have to use the position of the element/control. you can calculate the bounds and/or the location of the control and so you know in which monitor the element is. the handler will do his work in the backgound; even when its a touch or normal monitor. BUT AGAIN, if YOU want to know if it's a touchscreen or a normal monitor, then you have to wit until someone gives us a proper solution :)Damarisdamarra
I don't believe this property would exist. My expectation would be that you can tell whether a touch device is present, and (if it is present and is used to interact with an application) the application would receive input events from it, but I don't imagine that such a device is assigned an "effective area," as such.Uncovenanted
I think you'll find @DanPuzey is correct - a touch-enabled monitor is presented to the system as 2 devices - a monitor and a human interface device. In fact, you can buy kits that sit in front of a standard monitor to make it "touch enabled". In short, I think you're assuming a relationship which isn't necessarily valid. There's also the question of what happens when a window/control is half on one screen, half on another. Of course, there's nothing to stop you offering a setting for which area of the desktop should be considered touch-enabled and using that to decide.Hosier
Has anybody tested my answer? I'll have a touch screen to play with again soon, but I'm curious of the results or if someone has found a better way.Epicure
E
2

I don't have a touch screen to test this on, but you can probably use System.Windows.Input.Tablet to enumerate through the static TabletDevices property. The ActiveSource property can be compared against PresentationSource.FromVisual to see if your UIElement is on the TabletDevice. This may not be perfect, I'm not used to using these classes, but that should get you on the right track. TabletDevices also have a Name property which you may be able to compare against System.Windows.Forms.Screen.DeviceName.

Epicure answered 19/9, 2012 at 15:19 Comment(1)
I forgot to put edit notes, but I changed this from a very hypothetical answer to what I believe to be a correct (or close) solution.Epicure

© 2022 - 2024 — McMap. All rights reserved.