问题
I'm using this C#(wpf) code to detect touch screen on
return Tablet.TabletDevices.OfType<TabletDevice>().Any(dev => dev.Type == TabletDeviceType.Touch)
But it is not working. Tablet.TabletDevices Count is always 0. I'm using extension touch monitor(use USB connect PC for touch detect)
Is there any better way to check if current PC has touch screen or not?
Thanks.
Update1:
I don't know why but even when I remove the touch screen USB and monitor,
GetSystemMetrics(SM_MAXIMUMTOUCHES)still returns 1.Update2:
looks like that is not working, I mean use :
return GetSystemMetrics(SM_MAXIMUMTOUCHES) > 0Because it's always returning 1, even when I restart computer(win7 OS, laptop computer)
回答1:
I use a bit different approach, and it works for variety of touchscreens. It works from Win7 and up (as defined here, in section about SM_DIGITIZER setting).
bool touchDevicePresent()
{
return GetSystemMetrics(SM_DIGITIZER) & NID_READY;
}
回答2:
I guess this and this will help you.
来源:https://stackoverflow.com/questions/20923853/why-i-cant-detect-touch-screen