begin process at 2010 09 03 06:19:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Périphériques

 > ROTATION D'ÉCRAN

ROTATION D'ÉCRAN


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Périphériques Source .NET ( DotNet ) Classé sous :rotation, écran, ChangeDisplaySettingsEx, orientation, affichage Niveau :Débutant Date de création :15/08/2009 Date de mise à jour :15/08/2009 12:32:11 Vu / téléchargé :4 098 / 465

Auteur : Willi

Ecrire un message privé
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note


 Description

Cliquez pour voir la capture en taille normale
Voici une petite source montrant comment effectuer une rotation d'écran sur un écran en particulier.
Le code principal se décompose en 3 méthodes d'extensions de la classe System.Windows.Forms.Screen et Screen().
Elles permettent d'effectuer une rotation, d'obtenir l'orientation actuel de l'écran et de lister les noms des écrans.!

Source

  • Imports System.Runtime.CompilerServices
  • Module RotateScreen
  • Const ENUM_CURRENT_SETTINGS As Integer = -1
  • Const DISP_CHANGE_SUCCESSFUL As Integer = 0
  • Const DISP_CHANGE_BADDUALVIEW As Integer = -6
  • Const DISP_CHANGE_BADFLAGS As Integer = -4
  • Const DISP_CHANGE_BADMODE As Integer = -2
  • Const DISP_CHANGE_BADPARAM As Integer = -5
  • Const DISP_CHANGE_FAILED As Integer = -1
  • Const DISP_CHANGE_NOTUPDATED As Integer = -3
  • Const DISP_CHANGE_RESTART As Integer = 1
  • <Extension()> _
  • Public Function GetNames(ByVal param As System.Windows.Forms.Screen()) As String()
  • Dim x As New List(Of String) '= Array.CreateInstance(GetType(String), param.Length)()
  • For i As Integer = 0 To param.Length - 1
  • x.Add(param(i).DeviceName)
  • Next
  • Return x.ToArray()
  • End Function
  • <Extension()> _
  • Public Sub SetOrientation(ByVal param As System.Windows.Forms.Screen, ByVal value As System.Windows.Forms.ScreenOrientation)
  • Try
  • 'Récupère la config. actuelle.
  • Dim dm As DEVMODE = DEVMODE.Create()
  • NativeMethods.EnumDisplaySettings(param.DeviceName, ENUM_CURRENT_SETTINGS, dm)
  • 'Et suivant l'orientation déjà appliquée on échange largeur <-> longueur si besoin est.
  • Select Case dm.dmDisplayOrientation
  • Case System.Windows.Forms.ScreenOrientation.Angle0, System.Windows.Forms.ScreenOrientation.Angle180
  • If value = Windows.Forms.ScreenOrientation.Angle90 Or value = Windows.Forms.ScreenOrientation.Angle270 Then
  • Dim iswap As Integer = dm.dmPelsHeight
  • dm.dmPelsHeight = dm.dmPelsWidth
  • dm.dmPelsWidth = iswap
  • End If
  • Case System.Windows.Forms.ScreenOrientation.Angle90, System.Windows.Forms.ScreenOrientation.Angle270
  • If value = Windows.Forms.ScreenOrientation.Angle0 Or value = Windows.Forms.ScreenOrientation.Angle180 Then
  • Dim iswap As Integer = dm.dmPelsHeight
  • dm.dmPelsHeight = dm.dmPelsWidth
  • dm.dmPelsWidth = iswap
  • End If
  • End Select
  • dm.dmDisplayOrientation = value
  • 'Puis on applique le changement de paramètres.
  • NativeMethods.ChangeDisplaySettingsEx(param.DeviceName, dm, IntPtr.Zero, 0, IntPtr.Zero)
  • Catch ex As Exception
  • End Try
  • End Sub
  • <Extension()> _
  • Public Function GetOrientation(ByVal param As System.Windows.Forms.Screen) As System.Windows.Forms.ScreenOrientation
  • 'Récupère la config de l'écran demandée.
  • Dim dm As DEVMODE = DEVMODE.Create()
  • NativeMethods.EnumDisplaySettings(param.DeviceName, ENUM_CURRENT_SETTINGS, dm)
  • Return dm.dmDisplayOrientation
  • End Function
  • End Module
Imports System.Runtime.CompilerServices

Module RotateScreen

    Const ENUM_CURRENT_SETTINGS As Integer = -1

    Const DISP_CHANGE_SUCCESSFUL As Integer = 0
    Const DISP_CHANGE_BADDUALVIEW As Integer = -6
    Const DISP_CHANGE_BADFLAGS As Integer = -4
    Const DISP_CHANGE_BADMODE As Integer = -2
    Const DISP_CHANGE_BADPARAM As Integer = -5
    Const DISP_CHANGE_FAILED As Integer = -1
    Const DISP_CHANGE_NOTUPDATED As Integer = -3
    Const DISP_CHANGE_RESTART As Integer = 1

    <Extension()> _
    Public Function GetNames(ByVal param As System.Windows.Forms.Screen()) As String()

        Dim x As New List(Of String) '= Array.CreateInstance(GetType(String), param.Length)()

        For i As Integer = 0 To param.Length - 1
            x.Add(param(i).DeviceName)
        Next

        Return x.ToArray()

    End Function

    <Extension()> _
    Public Sub SetOrientation(ByVal param As System.Windows.Forms.Screen, ByVal value As System.Windows.Forms.ScreenOrientation)

        Try

            'Récupère la config. actuelle.
            Dim dm As DEVMODE = DEVMODE.Create()
            NativeMethods.EnumDisplaySettings(param.DeviceName, ENUM_CURRENT_SETTINGS, dm)

            'Et suivant l'orientation déjà appliquée on échange largeur <-> longueur si besoin est.
            Select Case dm.dmDisplayOrientation

                Case System.Windows.Forms.ScreenOrientation.Angle0, System.Windows.Forms.ScreenOrientation.Angle180

                    If value = Windows.Forms.ScreenOrientation.Angle90 Or value = Windows.Forms.ScreenOrientation.Angle270 Then
                        Dim iswap As Integer = dm.dmPelsHeight
                        dm.dmPelsHeight = dm.dmPelsWidth
                        dm.dmPelsWidth = iswap
                    End If

                Case System.Windows.Forms.ScreenOrientation.Angle90, System.Windows.Forms.ScreenOrientation.Angle270

                    If value = Windows.Forms.ScreenOrientation.Angle0 Or value = Windows.Forms.ScreenOrientation.Angle180 Then
                        Dim iswap As Integer = dm.dmPelsHeight
                        dm.dmPelsHeight = dm.dmPelsWidth
                        dm.dmPelsWidth = iswap
                    End If

            End Select

            dm.dmDisplayOrientation = value

            'Puis on applique le changement de paramètres.
            NativeMethods.ChangeDisplaySettingsEx(param.DeviceName, dm, IntPtr.Zero, 0, IntPtr.Zero)

        Catch ex As Exception

        End Try

    End Sub

    <Extension()> _
    Public Function GetOrientation(ByVal param As System.Windows.Forms.Screen) As System.Windows.Forms.ScreenOrientation

        'Récupère la config de l'écran demandée.
        Dim dm As DEVMODE = DEVMODE.Create()
        NativeMethods.EnumDisplaySettings(param.DeviceName, ENUM_CURRENT_SETTINGS, dm)

        Return dm.dmDisplayOrientation

    End Function

End Module

 Conclusion

A noter que cette fonctionnalité n'est pas supportée par tout les pilotes graphiques.
(Testé sous Windows 7)

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

15 août 2009 12:32:11 :
explication finale.

 Sources du même auteur

Source avec Zip Source .NET (Dotnet) LISTVIEW SUPPORT TRI MULTI-COLONNES PAR MÉTHODES D'EXTENSION...
Source avec Zip Source avec une capture Source .NET (Dotnet) IMAPI2 - GRAVER UN CD AUDIO
Source avec Zip Source avec une capture Source .NET (Dotnet) CONTRÔLES COLOR PICKER: WHEEL COLOR PICKER - SCREEN COLOR PI...
Source avec Zip Source .NET (Dotnet) [.NET3.5] EXTENSION METHODS: SUR LES CLASSES SYSTEM.IO
Source avec Zip Source avec une capture Source .NET (Dotnet) IMAPI2 - GRAVER UN FICHIER IMAGE ISO

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) VARIATEUR SECTEUR 11 VOIES SUR PORT SERIE OU USB par mays
Source avec Zip Source avec une capture PILOTER LES PORTS PARALLELES. par djebbipgm
Source avec Zip PILOTER LES PORT COMM DE PC par djebbipgm
Source avec Zip VISUALISATION ET EXPLOITATION DES DONNÉES DE TÉLÉINFORMATION... par MVI
Source avec Zip CAPTURE DES TRAMES DE TÉLÉINFORMATION DES COMPTEURS EDF (ÉLE... par MVI

 Sources en rapport avec celle ci

SCRIPT VBS D'IMPRESSION OU AFFICHAGE D'UN RÉPERTOIRE DEPUI... par djebbipgm
Source avec Zip Source avec une capture FAIRE UN CUBE EN 3D ET LE FAIRE TOURNER SANS UTILISER DIRECT... par zulrigh
Source avec Zip Source avec une capture AFFICHAGE DÉTAILLÉ DES PROCESSUS EN COURS D'EXÉCUTION SUR UN... par hackoo
Source avec Zip Source .NET (Dotnet) REPRESENTATION GRAPHIQUE D'UN MOT par ShayW
AFFICHER LES RÉSOLUTIONS D'ÉCRAN DISPONIBLES par lordxyp

Commentaires et avis

Commentaire de Londonic le 25/08/2009 14:29:40 10/10

Merci Willi 10/10

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Affichage d'une Variable [ par DoubleZeroCool ] Je n'arrive pas a passer la valeur d'une variable a l'écran.Le but est d'afficher a n'importe quel moment la valeur de la variable S à l'écran.S est n problème d'affichage étrange [ par jankoo ] En clair je veux afficher une fenêtre en 800*600 correctement.Je force la résolution en 800*600 et je passe en plein écran. Jusque-là pas de problème. Problème affichage [ par jfg1962 ] Bonjour à tous,Tout d'abord je dois dire que j'y connais presque que dalle...J'espère que dans le tas de super-balaises en informatique que vous êtes Common Dialog : Affichage [ par Amstelsoft ] Bonjour,Est-ce qu'il est possible d'afficher la fenetre "Enregistrer sous" à un endroit bien précis de l'écran : par exemple centrer la fenetre à l'éc Affichage d'un fond d'écran [ par PHILOUVB ] J'ai créé un programme qui me permet d'afficher des fonds d'écran différents chaque jour.Mais je me bloque à un petit problème. Lorsque l'ordinateur d Lancement d'une application [ par beabea ] Bonjour, Le lancement de mon application prend du temps car nous avons des pc non performants et un r&#233;seau pas tr&#232;s rapide. Aussi, jusqu'&#2 Affichage image sans form à l'écran [ par terrible ] Je recherche depuis plusieurs semaines le moyen d'afficher &#224; l'&#233;cran une image sans qu'elle soit inscrite dans une forme .je sais qu'il faut Rotation de l'écran par programmation [ par andrieuremi ] Bonjour &#224; Tous !Je sais que beaucoup de programmeurs se sont pos&#233;s la question.Alors je la pose:Connaissez-vous un script pour tourner l'ima Application en fond d'écran!! [ par setfocus ] Bonjour à tous,Je désirerai développer une application permettant l'affichage de données en fond d'écran.En effet, cet affichage permettrai de renseig Problème d'affichage d'une feuille Form1 [ par basamir ] Bonsoir,je viens de créer une application avec VB6 où j'ai une feuille form1 qui occupe tout l'écran de mon PC Portable, une fois installé dans d'autr


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Septembre 2010
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
27282930   

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,952 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales