Detecting tablet PC

前端 未结 3 598
故里飘歌
故里飘歌 2021-01-03 10:15

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 t

相关标签:
3条回答
  • 2021-01-03 10:27

    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

    0 讨论(0)
  • 2021-01-03 10:35

    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.

    0 讨论(0)
  • 2021-01-03 10:42

    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.

    0 讨论(0)
提交回复
热议问题