Detecting screen rotation

I am starting an application that is to be run on a Windows tablet (specifically Windows 10) and will need to detect if the user has rotated the screen. I can determine the screen orientation at start time but I need to be able to detect the “rotation event” so I can dynamically redraw the window. I’ve search the forum and the documentation but haven’t found a clue.

I would rather not go the route of using a timer and testing the screen width and height every couple of milliseconds unless that is the only way to do it.

Anyone solve this dilemma already?

  • Dale

I use the Resized event of the window, since it is usually full screen on tablets, to check which side is bigger than the other. Since windows cannot exceed the dimensions of the screen, the full screen window is resized as well when the device rotates.

If you use the timer to do the same with Screen(0), you do not need that every couple millisecond. Most tablets usually change orientation after half a second or so. 500 Milliseconds will do just the same.

If you feel like declares, look at
https://msdn.microsoft.com/en-us/library/ms812142.aspx

Looks like you could “subclass” (see the WFS) the window and trigger your own OrientationChanged event.

[quote=255687:@Michel Bujardet]I use the Resized event of the window, since it is usually full screen on tablets, to check which side is bigger than the other. Since windows cannot exceed the dimensions of the screen, the full screen window is resized as well when the device rotates.
[/quote]
Well, of course! I feel really stupid for not thinking of this.

Thanks,
Dale