Tablet screen orientation [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Tablet screen orientation [Resolved]

Post by Kwai chang caine »

Hello at all :D

I have a Windows 8 tablet and i search to can choose the orientation of the screen horizontal or vertical
Furthermore, i search to prevent windows to change automaticaly this orientation

Somebody have an idea ?

Have a good day
Last edited by Kwai chang caine on Mon Feb 16, 2015 10:32 am, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Tablet screen orientation

Post by netmaestro »

You can set and lock the screen orientation for your application like this:

Code: Select all


#ORIENTATION_PREFERENCE_NONE = 0
#ORIENTATION_PREFERENCE_LANDSCAPE = 1
#ORIENTATION_PREFERENCE_PORTRAIT = 2
#ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = 4
#ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = 8

Prototype SetDisplayAutoRotationPreferences(orientation_preference.i)
OpenLibrary(0, "user32.dll")

SetDisplayAutoRotationPreferences_.SetDisplayAutoRotationPreferences = GetFunction(0, "SetDisplayAutoRotationPreferences")

Debug SetDisplayAutoRotationPreferences_(#ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED)

CloseLibrary(0)
Dunno about locking the whole screen.
BERESHEIT
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: Tablet screen orientation

Post by JHPJHP »

Hi Kwai chang caine,

Not to over-post netmaestro, but I just spent the last hour writing the following scripts:
- Orientation.pb: locks the display orientation on a tablet for the current process
- Rotation.pb: rotates the display to a set orientation

See my post: Services, Stuff, and Shellhook
- Stuff/WindowStuff/DisplayStuff

Cheers!
Last edited by JHPJHP on Tue Feb 17, 2015 12:12 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Tablet screen orientation

Post by netmaestro »

Not to over-post netmaestro
No sweat, your treatment of the subject is much more comprehensive than mine.
BERESHEIT
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Tablet screen orientation

Post by JHPJHP »

Thanks netmaestro!

-------------------------------------------------

Hi Kwai chang caine,

NOTE:
- the DEVMODE Structure used in the Orientation example is included in the PureBasic IDE, but it's missing some required fields
- I declared my own _DEVMODE Structure, built using Microsoft documentation, but it still wasn't correct
- I added two "padded" fields: padding1.w, padding2.l that seemed to fix the problem

NB*: Tested on Windows 8.1, PureBasic 5.31 x86 / x64.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Tablet screen orientation

Post by Kwai chang caine »

First thanks a lot at you two for your answer 8)

I have tried all your codes with v5.31 and W8.1 and i have this results

@NETMAESTRO
Your code have no effect on my tablet :|
I have put the tablet in landscape position and run the code with #ORIENTATION_PREFERENCE_PORTRAIT and nothing happened ...
The result is good 1, but nothing
In the same time i have oppened the panel of screen resolution for see if the orientation combobox have changed and no, the combobox is always on "landscape"
I have try also #ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED and it's the same result

@JHPJHP
Your Lock Rotation code have no effect too :|
Debug result wrote:AR_ENABLED
ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED
Like for NETMAESTRO, my tablet is putting horizontaly, i look the panel of screen resolution and the combo is always in landscape mode

Your change Orientation works perfectlly :D
I see my screen rotating automaticaly 8)
The combo in panel screen resolution show "PORTRAIT" :D (Obviously when the screen is in PORTRAIT, other he show "LANDSCAPE") 8)

So i have thinking to run your lock code immediatly after, when my tablet is horizontal and the screen is vertical (portrait), for see if i can lock the mode on portrait, but the combo screen resolution panel always say "PORTRAIT" but if i turn my tablet, the mode is not locked, the screen return automaticaly to Landscape mode :cry:

Furthermore, i have a strange behaviour, if i touch the desktop, or the Panel screen resolution, the screen automaticaly return to landscape mode, and the combo screen resolution show "LANDSCAPE"

Again thanks to have spent one hour for help me :shock:

I have really to much chance to know the members of this forum, never i have see so much generosity 8)

@Friends
Thanks again at you two 8)
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Tablet screen orientation

Post by netmaestro »

I hope you understand that the code I posted is only going to set the orientation for your application window, the rest of the screen will change orientation with movement.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Tablet screen orientation

Post by Kwai chang caine »

Yeeeeeesss !!! you have right !!!!!!

After reading your last post, i have adding :

Code: Select all

If OpenWindow(0, 0, 0, 220, 100, "Exemple...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   ButtonGadget  (1, 10, 60, 200, 30, "Fermer")
   
   Repeat
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 1 
              CloseWindow(0)
              End  
         EndSelect
            
     EndSelect
   Until Event = #PB_Event_CloseWindow
 EndIf
after your two codes

And like usually you have right, KCC have always not understand :oops:
Me i believe, you change the behaviour of Windows in the panel screen resolution, the combo of Landscape or Portrait, and perhaps also uncheck the CheckBox "Allow the automatic rotation of the screen"

But in fact your two codes is again better, because it modify the orientation of the screen without changing the orientation for the other applications ...too much cool !!!!

Again one thousands of thanks at you two to continue to spent your time for a lost cause, that is, in other world...me :mrgreen: :oops: :oops:
I'm so proud to know you

Have a very good day

Your fan for the life
Kcc 8)
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Tablet screen orientation [Resolved]

Post by netmaestro »

I don't know what the hell we'd do without you around here, KCC. It'd be f**king... dreary. Dreary and boring. Never disappear, because then we'd just be another coding forum.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Tablet screen orientation [Resolved]

Post by Kwai chang caine »

:lol: 8)
This kind sentence go directly in my heart 8)

I not have chance to love programming.... :cry:
It's better for me to love washing clothes, looking flowers, making bread, etc...

Unfortunately, since he was young, KCC love programming, and the PC :?
Again worst, KCC with his intelligence quotient of an oyster, thanks to FRED and his amazing PureBasic can just make a windows with only one button..and it's already very good 8)

But no.... Kcc is not happy of that, he want play in the big league :?
He see so much big brain in this forum, he forget his oyster brain :oops: , and believe he can also, twist and tame windows, like all his heroes of the forum.... :shock:
But even after numerous hours in front of the PB IDE, KCC have often, the white page syndrome, of the writter... :oops:

But thanks to you all my friends, KCC know now, he can often touch is goal, because he have an "USB external Brain storage" named PB FORUM :mrgreen:
And with all my splendid MASTERS i love...i can brave all the danger without risk 8)

Image

The day i met PureBasic....never i can imagine the enormous generosity, kindness, forbearance, and giants knowledges, hidden behind this several letters PB Forum

Thanks to you all to exist....
You are my second familly..
And you made my life all the days !!
8)
ImageThe happiness is a road...
Not a destination
northstarex
New User
New User
Posts: 4
Joined: Sun Aug 13, 2023 4:44 pm
Location: Supermario Land
Contact:

Re: Tablet screen orientation

Post by northstarex »

JHPJHP wrote: Mon Feb 16, 2015 1:04 am Hi Kwai chang caine,

Not to over-post netmaestro, but I just spent the last hour writing the following scripts:
- Orientation.pb: locks the display orientation on a tablet for the current process
- Rotation.pb: rotates the display to a set orientation

See my post: Services, Stuff, and Shellhook
- Stuff/WindowStuff/DisplayStuff

Cheers!
hi
sorry for reopening this old thread. Where can I find this Orientation.pb and Rotation.pb? I can't do anything with the links. thx :)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Tablet screen orientation [Resolved]

Post by Kwai chang caine »

Hello northstarex :D

Apparently... like JhpJhp explain here
viewtopic.php?p=603676#p603676
he have replaced his site
https://www.mypurebasicstuff.com/
by a personal Forum :shock:
https://www.mypurebasicstuff.com/forum/

You can perhaps found his code inside :wink:
ImageThe happiness is a road...
Not a destination
Olli
Addict
Addict
Posts: 1200
Joined: Wed May 27, 2020 12:26 pm

Re: Tablet screen orientation [Resolved]

Post by Olli »

northstarex wrote:sorry for reopening this old thread.
:lol:

I hadn't seen this topic!
kcc wrote:I not have chance to love programming.... :cry:
It's better for me to love washing clothes, looking flowers, making bread, etc...
:shock:

:lol:

Be careful : Processors in washing machines are becoming more and more sophisticated !
kcc wrote:[...], looking flowers, [...]
The mythomaniac ! The flowers that real suffer the consequences of clogged toilets !
northstarex
New User
New User
Posts: 4
Joined: Sun Aug 13, 2023 4:44 pm
Location: Supermario Land
Contact:

Re: Tablet screen orientation [Resolved]

Post by northstarex »

Kwai chang caine wrote: Tue Aug 15, 2023 3:54 pm Hello northstarex :D

Apparently... like JhpJhp explain here
viewtopic.php?p=603676#p603676
he have replaced his site
https://www.mypurebasicstuff.com/
by a personal Forum :shock:
https://www.mypurebasicstuff.com/forum/

You can perhaps found his code inside :wink:
What does the JhpJhp actually dream at night? You will be greeted with a payment request. Great website concept :lol: :D
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Tablet screen orientation [Resolved]

Post by Kwai chang caine »

Olli wrote:I hadn't seen this topic!
it also often happens to me not to have seen an old thread and to be happy to see it coming up after many years :wink:
But FRED doesn't really like it :cry:
Northstarex wrote:You will be greeted with a payment request. Great website concept
Yes i know, but it's not new !!!
There are a long time JhpJhp ask money for have the source code, even before his new forum
And nobody is forced to pay :wink:

There are a tons of works created by JhpJhp, since numerous years :shock:
And since a long time, all this numerous codes were free 8)
Furthermore JhpJhp often help all members when they ask questions 8)
He is a very important member of our family 8)

Now, everybody do what he think is good for him,
Sure .... i can't say it's better now :cry:
But if JhpJhp think all his montruous work need money for have it, it's he strictest right of JhpJhp 8)

Others several members give their executables, others give their numerous sources code too and help everyday all members, and i'm the first to thanks them each time i can do that Image, others give nothing at all and are when even importants members of the forum 8)

Here, everyone does what they want (Chacun fait ce qui lui plait) [Very big success French song of the 80's] :mrgreen:

Image

That's the lesser of it :wink:
ImageThe happiness is a road...
Not a destination
Post Reply