Results 1 to 16 of 16

Thread: [RESOLVED] How to force screen rotation?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Resolved [RESOLVED] How to force screen rotation?

    I'll start off with "I have no code for this" as I don't know where to even start (or if it can be done).

    The target device is a W10 SP tablet. Auto-Rotate would be disabled by default.

    What I would like to do is have a way of "forcing" Windows to flip the display (the whole screen, not the app) 180deg (as if auto-rotate was on and it had just been tilted upside-down, but without doing it). Can this be done and if so how?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    This is old so I don't know if it is still directly applicable:

    https://msdn.microsoft.com/en-us/library/ms812499.aspx

    There may be a newer API available but I just found that by searching for ".net windows 10 rotate screen programmatically". That's where you should start: with logical keywords in a web search.

  3. #3
    Fanatic Member kpmc's Avatar
    Join Date
    Sep 2017
    Posts
    1,012

    Re: How to force screen rotation?

    First thing that comes to my mind is SendKeys ctrl+alt+down cursor
    maybe a bit ghetto, and may not even work at all.

  4. #4
    Fanatic Member kpmc's Avatar
    Join Date
    Sep 2017
    Posts
    1,012

    Re: How to force screen rotation?

    That's where you should start: with logical keywords in a web search.
    Do you mean like.... google??

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    I did see that page already, but wasn't willing to even test it given how old it is. I didn't want to risk screwing up W10.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    So did you search the web specifically for information regarding Windows 10 and that API? It seems that you really did know where to start after all but thought it would be a good idea to mislead us and withhold relevant information for some reason.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    No, I just didn't see a that a page/solution meant for Windows XP to be worth bringing up when dealing with Windows 10. Sorry.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    So you know for a fact that that API doesn't work in Windows 10?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    okay, lets try this another way.

    I started my search on google and found that article. Given that W XP and W10 (to my limited understanding) are completely different OS's, I closed the page and kept looking. No I have not tried that solution, as I had no reasonable expectation (in my mind anyway) that a) it would work and b) it wouldn't break something. I'm more than willing to test random code when it comes to forms, but when it comes to the OS if I don't know it will work (or at least be safe) I'm not going to touch it.

    I thought I was being semi-smart about it. But I gather from your response that you don't agree.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    Quote Originally Posted by CWITT View Post
    Given that W XP and W10 (to my limited understanding) are completely different OS's
    They aren't. Every new version of Windows brings new features and functionality but there's still huge swathes of code that makes the trip to a new version intact. Even if there are new APIs to do certain things, it doesn't mean that old ones don't work any more. I don't know for sure either way with that info but, if there's a new managed API for this, it's likely UWP-specific anyway.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    Again, this is my limited knowledge speaking.. but isn't UWP apps that run "in" windows (like Forms of old)? If that is true, then how would a UWP tool have anything to do with altering the core windows display?

    (not trying to be difficult, fyi)

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    If you want to affect Windows from your application then you have basically two choices:

    1. You can invoke the Windows API directly.
    2. You can invoke an API that someone (you, Microsoft or a third party) has written that will invoke the Windows API.

    Microsoft have created managed APIs that are accessible only to UWP that can do things on Windows 10, which is the only Windows version that supports UWP, that other technologies (WinForms, WPF, etc) cannot do without invoking an older API. Basically, a lot of the dirty work is built into UWP but you need to get your hands dirty when using older technologies. The same is true of Windows Forms in comparison to VB6, where you're forced to resort to direct Windows API calls even more.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    ah, that's the best explanation I've ever seen about the differences. thank you.

    I guess it's time I start looking into UWP in general.

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to force screen rotation?

    Using UWP means developing a Store app, which may or may not be desirable.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: How to force screen rotation?

    it does? oh.

    ok, so slight topic shift. Ignoring UWP, what is the better format WPF or Windows Forms? Thus far everything I've done is in Windows Forms....

  16. #16
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: How to force screen rotation?

    Quote Originally Posted by CWITT View Post
    it does? oh.

    ok, so slight topic shift. Ignoring UWP, what is the better format WPF or Windows Forms? Thus far everything I've done is in Windows Forms....

    One question per thread so this thread would require its own. How ever that question is something that would of been asked countless of times and answered already over the internet.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width