Detecting tablet PC

前端 未结 3 597
故里飘歌
故里飘歌 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: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.

提交回复
热议问题