PointerDevice 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
支持识别连接的指针设备并确定其功能的功能。
public ref class PointerDevice sealed
	/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
class PointerDevice final
	[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
public sealed class PointerDevice
	Public NotInheritable Class PointerDevice
		- 继承
 
- 属性
 
Windows 要求
| 设备系列 | 
					 
							Windows 10 (在 10.0.10240.0 中引入) 
				 | 
			
| API contract | 
					 
							Windows.Foundation.UniversalApiContract (在 v1.0 中引入) 
				 | 
			
示例
以下代码演示如何使用 PointerDevice。
/// <summary> 
/// Invoked when this page is about to be displayed in a Frame. 
/// </summary> 
/// <param name="e">Event data that describes how this page was reached.  The Parameter 
/// property is typically used to configure the page.</param> 
protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 
    string Buffer; 
    Buffer = "List of all pointer devices: \n\n"; 
    var PointerDeviceList = Windows.Devices.Input.PointerDevice.GetPointerDevices(); 
    int displayIndex = 1; 
    foreach (Windows.Devices.Input.PointerDevice PointerDevice in PointerDeviceList) 
    { 
        Buffer += string.Format("Pointer device " + displayIndex + ":\n"); 
        Buffer += string.Format("This pointer device type is " + 
            PointerType(PointerDevice) + "\n"); 
        Buffer += string.Format("This pointer device is " + 
            (PointerDevice.IsIntegrated ? "not " : "") + "external\n"); 
        Buffer += string.Format("This pointer device has a maximum of " + 
            PointerDevice.MaxContacts + " contacts\n"); 
        Buffer += string.Format("The physical device rect is " + 
            PointerDevice.PhysicalDeviceRect.X.ToString() + ", " + 
            PointerDevice.PhysicalDeviceRect.Y.ToString() + ", " + 
            PointerDevice.PhysicalDeviceRect.Width.ToString() + ", " + 
            PointerDevice.PhysicalDeviceRect.Height.ToString() + "\n"); 
        Buffer += string.Format("The screen rect is " + 
            PointerDevice.ScreenRect.X.ToString() + ", " + 
            PointerDevice.ScreenRect.Y.ToString() + ", " + 
            PointerDevice.ScreenRect.Width.ToString() + ", " + 
            PointerDevice.ScreenRect.Height.ToString() + "\n\n"); 
    }  
    PointerOutputTextBlock.Text = Buffer; 
}
#include <sstream>
#include <winrt/Windows.Devices.Input.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
using namespace winrt;
using namespace Windows::Devices::Input;
using namespace Windows::UI::Xaml::Controls;
...
void PointerGetSettings_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args)
{
    auto b{ sender.try_as<Button>() };
    if (b)
    {
        Windows::Foundation::Collections::IVectorView<PointerDevice> pointerDeviceList{ PointerDevice::GetPointerDevices() };
        std::wostringstream buffer;
        for (uint32_t i = 0; i < pointerDeviceList.Size(); i++)
        {
            winrt::hstring displayIndex{ winrt::to_hstring(i + 1) };
            buffer << L"Pointer device " << displayIndex.c_str() << std::endl;
            buffer << L"This pointer device type is ";
            switch (pointerDeviceList.GetAt(i).PointerDeviceType())
            {
            case PointerDeviceType::Mouse:
                buffer << L"Mouse" << std::endl;
                break;
            case PointerDeviceType::Pen:
                buffer << L"Pen" << std::endl;
                break;
            case PointerDeviceType::Touch:
                buffer << L"Touch" << std::endl;
                break;
            default:
                buffer << L"unknown" << std::endl;
            }
            buffer << L"This pointer device is " << (pointerDeviceList.GetAt(i).IsIntegrated() ? L"not " : L"") << L"external" << std::endl;
            buffer << L"This pointer device has a maximum of " << pointerDeviceList.GetAt(i).MaxContacts() << L" contacts" << std::endl;
            buffer << L"The physical device rect is " <<
                pointerDeviceList.GetAt(i).PhysicalDeviceRect().X << L", " <<
                pointerDeviceList.GetAt(i).PhysicalDeviceRect().Y << L", " <<
                pointerDeviceList.GetAt(i).PhysicalDeviceRect().Width << L", " <<
                pointerDeviceList.GetAt(i).PhysicalDeviceRect().Height << std::endl;
            buffer << L"The screen rect is " <<
                pointerDeviceList.GetAt(i).ScreenRect().X << L", " <<
                pointerDeviceList.GetAt(i).ScreenRect().Y << L", " <<
                pointerDeviceList.GetAt(i).ScreenRect().Width << L", " <<
                pointerDeviceList.GetAt(i).ScreenRect().Height << std::endl << std::endl;
        }
        PointerOutputTextBlock().Text(buffer.str());
    }
}
void SDKSample::DeviceCaps::Pointer::PointerGetSettings_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    Button^ b = safe_cast<Button^>(sender); 
    if (b != nullptr) 
    { 
        Windows::Foundation::Collections::IVectorView<PointerDevice^>^ PointerDeviceList = PointerDevice::GetPointerDevices(); 
        Platform::String^ Buffer; 
        for (unsigned i = 0; i < PointerDeviceList->Size; i++) { 
            Platform::String^ displayIndex = (i + 1).ToString(); 
            Buffer += "Pointer device " + displayIndex + ":\n"; 
            Buffer += "This pointer device type is " + PointerType(PointerDeviceList->GetAt(i)) + "\n"; 
            Buffer += "This pointer device is " + (PointerDeviceList->GetAt(i)->IsIntegrated ? "not " : "") + "external\n"; 
            Buffer += "This pointer device has a maximum of " + PointerDeviceList->GetAt(i)->MaxContacts.ToString() + " contacts\n"; 
            Buffer += "The physical device rect is " + 
                PointerDeviceList->GetAt(i)->PhysicalDeviceRect.X.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->PhysicalDeviceRect.Y.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->PhysicalDeviceRect.Width.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->PhysicalDeviceRect.Height.ToString() + "\n"; 
            Buffer += "The screen rect is " + 
                PointerDeviceList->GetAt(i)->ScreenRect.X.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->ScreenRect.Y.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->ScreenRect.Width.ToString() + ", " + 
                PointerDeviceList->GetAt(i)->ScreenRect.Height.ToString() + "\n\n"; 
        } 
        PointerOutputTextBlock->Text = Buffer; 
    } 
}
	注解
此处讨论的属性返回的值基于连接的指针设备总数:如果一台设备支持特定功能,则布尔属性返回 true,数值属性返回所有设备公开的最大值。
设备功能示例演示如何检测输入设备是否存在并检索每个设备的功能和属性。
注意
此类不是敏捷类,这意味着需要考虑其线程模型和封送处理行为。 有关详细信息,请参阅线程处理和封送处理 (C++/CX) 和在多线程环境中使用 Windows 运行时 对象 (.NET) 。
属性
| IsIntegrated | 
		 获取一个值,该值指示指针设备是否为集成设备。 例如,与外部笔/触笔数字化器相比,具有集成触摸数字化器的视频显示器。  | 
        	
| MaxContacts | 
		 获取一个值,该值指示输入设备支持的最大触点数。  | 
        	
| MaxPointersWithZDistance | 
		 获取输入设备支持的悬停触点的最大数目。  | 
        	
| PhysicalDeviceRect | 
		 获取输入设备支持的边框的坐标。  | 
        	
| PointerDeviceType | 
		 获取指针设备类型。  | 
        	
| ScreenRect | 
		 获取映射到输入设备支持的边框的屏幕坐标。  | 
        	
| SupportedUsages | 
		 获取包含支持的 指针设备用法的集合。  | 
        	
方法
| GetPointerDevice(UInt32) | 
		 获取与指定输入指针 ID 关联的指针设备的相关信息。  | 
        	
| GetPointerDevices() | 
		 获取有关附加到系统的指针设备的信息。  |