Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hello there developers,
need access threw code to set the screen orientation of the desktop by one click.
first, i want to check if the screen orientation is horizontal or vertical.
then, from status a change it to b by one click.
also, assuming i have 2 screens, how can i get access to the secondary screen?
what that i have so far is this:
VB
Dim theScreenHeight As Integer
Dim theScreenWidth As Integer
theScreenHeight = Screen.PrimaryScreen.Bounds.Height
theScreenWidth = Screen.PrimaryScreen.Bounds.Width
If (theScreenHeight > theScreenWidth) Then
   'change to vertical
Else
   'change to horizontal
End If


thanks a head,
oron
Posted

I'm sorry that I posted you a Link with an Information, which isn't working. I thought that posts on MSDN would word - my mistake. By searching in the Internet I found more Snippets like the posted one, which have nearly the same code.

But now I have a Link for you which guides you to a working solution : https://www.vb-paradise.de/index.php/Thread/68853-alle-bildschirmaufloesungen-ermitteln-und-wechseln/[^]

I hope, that it is not a big problem for you that the linked Forum is a German one.
You only have to load the ZIP-File and the end of the Thread at the User 'Erfinder des Rades' (Inventor of the Wheal).

This Code I have tested and it works ... ;)

Greetings
Ralf
 
Share this answer
 
Comments
oronsultan 2-Jun-15 16:28pm    
Dear ralf,
the link is better than i thought!
thank a lot for the hard work, you are the- man!
Ralf Meier 3-Jun-15 0:35am    
you are welcome - every time again ...
If you wnat the second screen (and additional screens). You loop through Screen.AllScreens and all that are not equal to the Screen.PrimaryScreen is the 2nd, 3rd, etc... screen.

In c# something like this:
var otherScreens = Screen.AllScreens.Where(x => x != Screen.PrimaryScreen);


Good luck!
 
Share this answer
 
Comments
oronsultan 2-Jun-15 6:11am    
thanks a lot for the quick reply...
but still, how can i set the screen orientation threw code?
Ralf Meier 2-Jun-15 6:36am    
Do you want to change the Windows-Settings ?
Or do you want to see how they are ?
E.F. Nijboer 2-Jun-15 9:55am    
Check here for more on screen orientation:
https://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.systemsettings.screenorientation%28v=vs.85%29.aspx
oronsultan 2-Jun-15 6:39am    
both. in order to determine if to set the view to horizontal or vertical i need first to check the current status (allready got it :-)) and then flip it, so yeah, both.
Ralf Meier 2-Jun-15 6:46am    
... then the Orientation is the relation from width to height.
In the Moment I don't understand the Problem in the right way ...
 
Share this answer
 
Comments
oronsultan 2-Jun-15 7:30am    
snippes you from the article you gave me:
Case DISP_CHANGE_SUCCESSFUL
'Resolution was changed
'This is not an assurance that the new resolution will render
'proprely on every system. It only means that the registery was
'updated succesfuly and that the driver have not return any
'error
Return ChangeResult.Success
i buield a program according to this code and nothing changes.
but thanks aniway :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900