#736 – 通过代码获取硬件支持的最大触摸点数(Finding the Maximum Number of Touch Points at Run-time)

原文地址;https://wpf.2000things.com/2013/01/17/736-finding-the-maximum-number-of-touch-points-at-run-time/

我们可以使用Win32的API函数GetSystemMetrics 获取硬件支持的最大触摸点数。

class Program
{
    [DllImport("user32.dll")]
    static extern int GetSystemMetrics(int nIndex);
 
    // Index passed in to GetSystemMetrics() indicates
    // what data we're asking for.
    private const int SM_DIGITIZER = 94;
    private const int SM_MAXIMUMTOUCHES = 95;
 
    // Masks used to check results from SM_DIGITIZER check
    private const int NID_READY = 0x80;
    private const int NID_MULTI_INPUT = 0x40;
 
    static void Main(string[] args)
    {
        string info;
 
        int digitizer = GetSystemMetrics(SM_DIGITIZER);
 
        if ((digitizer & (NID_READY + NID_MULTI_INPUT)) == NID_READY + NID_MULTI_INPUT)
        {
            int numTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES);
            info = string.Format("Multitouch ready, {0} inputs supported", numTouchPoints);
        }
        else
            info = "Multitouch not supported";
 
        Console.WriteLine(info);
        Console.ReadLine();
    }
}

打印出结果如下:

736-001

你可以在“控制面板”->“系统”页中查看。

阅读更多
个人分类: WPF C#
上一篇#734 – 在触摸事件中识别不同的手指(Recognizing Different Fingers in Touch Event Handlers)
下一篇#741 – 使用触摸事件移动控件(Using Touch Manipulation Events to Translate an Element)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭