How to detect if Windows 10 is in tablet mode - winapi

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.

You can use UIViewSettings.UserInteractionMode #Raymond pointed out.
Refer to "Tablet mode" "How can I detect whether my PC is in tablet mode?"

Related

How to simulate an incoming call within the windows phone simulator?

I need to test how my app reacts when an incoming call interrupts execution. How can I do this in the simulator?
Go to Properties of your App(right click on solution Explorer), Select Debug tab and there you will find a checkbox(Tombstone upon deactivation while debugging), check that. After checking it whenever the apps gets deactivated , it will get in to tombstone state while debugging.
I think that Scenario is not possible to Test in Emulator. You can make call from your app in emulator but Receiving can be tested in only Device. for more Reference you can refer this Question Windows Phone 7 emulator : Can I simulate a phone call.
To test for making a call from your app, you can find Reference here How to use the phone call task for Windows Phone 8

Starting my app when USB device connected

I need to starting my app when our USB device connected.
My first attempt at this is a background application that pays attention to when USB devices are plugged in. When it notices our device connected, it calls ShellExecute( ) and starts our application.
This works nicely except in Windows 8. Supposing we're on the "Start" screen in Windows 8. In that situation, the application starts in the background and the start screen remains in front.
I think this is a "focus" problem since what I'm actually hoping to do is "steal focus" from the Start screen.
http://blogs.msdn.com/b/oldnewthing/archive/2009/02/20/9435239.aspx
Since my background application doesn't have focus (the Start screen has focus; besides, my application doesn't have a UI), it can't give focus away to my foreground application.
Let me say that in general, I hate focus stealing. Starting the app the user wants to use is a great help to our users.
How can I fix this problem? Maybe the answer is to programmatically ask the start screen to start my app but I don't see a way to do that:
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/9ed23f32-0708-48a8-9ff7-5fce6dbe123f/windows-8-start-screen-api
Maybe I'm approaching this in the wrong way. Suggestions?
You're going about this the wrong way. Although you can write a program to constantly monitor the USB ports to detect when something is connected, there's no need. The OS is already doing that anyway.
Register an Autoplay handler for your device type and class. This is distinct from the old AutoRun feature, which would automatically execute programs found on an inserted file system.
You can begin with an overview of the feature from the November 2001 issue of MSDN Magazine.
Your handler will be a COM DLL. You can register the DLL as a handler, and register the handler with events you want to handle. You can either perform everything in the DLL, or you can put the bulk of the functionality in your application and just use the DLL as a proxy between the OS and your program.

How to detect if Windows 8 is showing desktop

In a Windows desktop application written in C# and running on Windows 8 how can I detect if Windows 8 is in desktop mode (i.e. showing the Desktop rather than the modern UI)?
Although it's in C++, the Start Screen Visibility Sample should be a good starting point for you. It uses COM objects to get the state of all monitors on the system that are either displaying Windows Store Apps or the Start Screen, and illustrates how to receive notifications when the state of a monitor changes or when the visibility of the Start screen changes.

Is there an analogue of Windows Phone 'User Idle Detection' in Windows 8?

I've used the following code on Windows Phone 7 and 8 to disable user idle detection when my App is displaying data to the user and they are unlikely to interact with the screen e.g. A recipe App where the screen needs to stay on:
http://msdn.microsoft.com/en-us/library/microsoft.phone.shell.phoneapplicationservice.useridledetectionmode(v=vs.92).aspx
Does anyone know if there is an analogue of this available for Windows 8 applications? My tablet app has the same requirement to disable the screen turning off. I haven't managed to find anything :-(
Many thanks,
Jon
You should use the DisplayRequest class, specifically DisplayRequest.RequestActive for this purpose. You must also remember to call DisplayRequest.RequestRelease once you are done to allow the display to sleep, for example, if you are not viewing a recipe, or you are in a menu screen, etc.

Is there a way to simulate tombstoning on the windows phone 7 emulator?

One of the requirements for a Windows Phone 7 application that I am writing is to handle the app going into standby and back when something interrupts it (e.g. a phone call). This is called "tombstoning" an application. Is there a way to simulate this behavior on the emulator? It will be fairly difficult to test unless we can either do this or get an actual phone (the latter of which is a trifle difficult).
You can simulate tombstoning by simply pushing (clicking) on the start or search "hardware" buttons on the emulator. This will cause your app to be "tombstoned".
There is no way to simulate incoming calls, etc. on the emulator.
Check out these two topic sections for details on what Matt/Amenti describe:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff806372(v=vs.105).aspx#BKMK_Toforceanapplicationstatechangefordebuggingpurposes
and
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff806372(v=vs.105).aspx#BKMK_Toforceanapplicationstatechangefordebuggingpurposes

Resources