Detecting tablet PC

僤鯓⒐⒋嵵緔 提交于 2020-01-23 01:45:25

问题


I have a .net winforms application which some users will run on Win7 tablets. For those users, I want to change certain UI elements to make pen input easier, while leaving those items alone for regular users. I've been able to find msdn docs on design guidelines for pen & touch, and nitty gritty on e-ink and such, but nothing on just detecting "Does this machine support a stylus or touch". Any hints?


回答1:


A. Use the Windows GetSystemMetricsAPI and pass in SM_TABLETPC as the value of the index. SM_TABLETPC is defined in Winuser.h. The value of SM_TABLETPC is 86.

For web development, you should read the USER_AGENT_STRING environment variable. You can access this Request.ServerVariables collection.

For details of how to use GetSystemMetrics on Tablet PCs running either Windows Vista or Windows XP Tablet PC Edition, refer to Determining Whether a PC is a Tablet PC.

Sources

Determining Whether a PC is a Tablet PC

MSDN Windows Tablet - Frequently Asked Questions




回答2:


See msdn post. They have a routine in that page

using System.Runtime.InteropServices;
[DllImport("user32.dll")]
private static extern int GetSystemMetrics(int nIndex);
// System metric constant for Windows XP Tablet PC Edition
private const int SM_TABLETPC = 86;
private readonly bool tabletEnabled;

protected bool IsRunningOnTablet()
{
    return (GetSystemMetrics(SM_TABLETPC) != 0);
}

See if this helps.




回答3:


In addition to the accepted answer you should also give the user the possibility to manually change between tablet and non-tablet mode. The detection could fail or the operating system is not used in the way it was designed too. This can happen on embedded devices which use a non-tablet-OS with special software as also the other way around.



来源:https://stackoverflow.com/questions/5795010/detecting-tablet-pc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!