4

I'm trying to find a method to detect if Windows 10 is in tablet mode or not. Please note, this is not about querying whether the user has a Tablet PC or not - that can be solved with GetSystemMetrics(SM_CONVERTIBLESLATEMODE). In my case the above function always returns 0 - whether Win10 is in tablet mode or not.

This thread without an epilogue seems to suggest that there is no WinAPI call that could detect Tablet mode. I hope that isn't the case, since there are different WM messages posted by the OS if it's in tablet mode or not. In tablet mode WM_SHOWWINDOW isn't sent which means I need to address the launching of the application differently if Windows 10 is in tablet mode.

I could just move the code that is currently triggered after receiving the WM_SHOWWINDOW message somewhere else (just after ShowWindow is called), but then I get a WM_DPICHANGED message with null parameters.

Dan
  • 107
  • 6

1 Answers1

2

You can use UIViewSettings.UserInteractionMode @Raymond pointed out.

Refer to "Tablet mode" "How can I detect whether my PC is in tablet mode?"

Rita Han
  • 9,574
  • 1
  • 11
  • 24
  • 1
    Um, this is not documented or supported. Use the supported API: UserInteractionMode. – Raymond Chen Mar 19 '19 at 06:12
  • The samples on the blog from @RaymondChen and on the Windows docs page mentioned by @RitaHan seem to be what I'm looking for. However after implementing them, I get a `pointer to incomplete type not allowed` message for `uiViewSettingsInterop->GetForWindow` even though I'm including `UIViewSettingsInterop.h `. My `NTDDI_VERSION` is 0x0603 (targeting Win8.1 and up). Am I missing something obvious? – Dan Mar 19 '19 at 09:31
  • 1
    `IUIViewSettingsInterop` is supported starting in Windows 10. Notice that the definition of `IUIViewSettingsInterop` is inside `#if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)`. – Raymond Chen Mar 19 '19 at 18:52