How to detect tablet mode

前端 未结 1 1181
名媛妹妹
名媛妹妹 2021-01-11 09:44

I\'m using the following code to detect if a user is in tablet mode or not. I\'m on a Surface Pro and when I decouple the keyboard and make the PC into a tablet, IsTab

相关标签:
1条回答
  • 2021-01-11 10:13

    Edit 2: The SM_TABLETPC is only supported by Windows XP Tablet PC Edition and Windows Vista. There doesn't seem to be any reference to Windows 10 here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms700675(v=vs.85).aspx

    You can use this: GetSystemMetrics(SM_CONVERTIBLESLATEMODE). A “0” returned means it is in tablet mode. A “1” returned means it is in non-tablet mode. https://software.intel.com/en-us/articles/how-to-write-a-2-in-1-aware-application

    Can you replace the QueryTabletMode method with this:

       private static Boolean QueryTabletMode ()
       {
           int state = GetSystemMetrics(SM_CONVERTIBLESLATEMODE);
           return (state == 0);
       }
    

    Edit: You might need to check this periodically as there's no event to see if the PC's tablet mode was turned on

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