Is it possible to let my c# wpf program know if the user has a touchscreen or not?

前端 未结 3 1542
礼貌的吻别
礼貌的吻别 2020-12-06 17:00

I\'ve got an login application that has a swipe system that people only can use when they have a touchscreen. They can login by swiping their personal pattern swipe code.

相关标签:
3条回答
  • 2020-12-06 17:37

    I don't think there's anything available in managed code but you could use P/Invoke on Win32_DesktopMonitor. For more information see msdn.

    I found this blog-post that might be of help even though it's on Windows CE: http://blog.nerdbank.net/2006/10/platform-detection-iii-how-to-detect.html

    0 讨论(0)
  • 2020-12-06 17:38

    There is IInkTablet2 COM interface in Windows XP Tablet PC Edition or managed wrapper Microsoft.Ink.Tablet class for non-WPF applications. But it most of touch screen drivers are "mouse" drivers and can't be detected in this way.

    0 讨论(0)
  • 2020-12-06 17:53

    Within C# code to find out if a touch screen exists (doesn't check if its a single or multi-touch device though) by the using System.Windows.Input namespace in PresentationCore.

        public bool HasTouchInput()
        {
            foreach (TabletDevice tabletDevice in Tablet.TabletDevices)
            {
                //Only detect if it is a touch Screen not how many touches (i.e. Single touch or Multi-touch)
                if(tabletDevice.Type == TabletDeviceType.Touch)
                    return true;
            }
    
            return false;
        }
    
    0 讨论(0)
提交回复
热议问题