Positionner une fenetre dans windows

Résolu
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015 - 1 avril 2007 à 20:41
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015 - 2 avril 2007 à 00:20
Hello

Comment positionner une form en bas et à droite de l'écran au dessus de la barre de tâche selon la résolution de l'écran ?

Merci de votre aide à tous

Bye

8 réponses

cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
1 avril 2007 à 21:38
re

Voilà ce que j'ai fait pour l'instant mais pas top:

Dim

x
As
Integer

Dim y
As
Integer

If Screen.PrimaryScreen.Bounds.Width = 1280
Then x = (Screen.PrimaryScreen.Bounds.Width / 2) + 385 :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 960
Then y = (Screen.PrimaryScreen.Bounds.Height / 2) + 195 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 1152
Then x = (Screen.PrimaryScreen.Bounds.Width / 2) + 320 :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 864
Then y = (Screen.PrimaryScreen.Bounds.Height / 2) + 150 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 1024
Then x = (Screen.PrimaryScreen.Bounds.Width / 2) + 260 :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 768
Then y = (Screen.PrimaryScreen.Bounds.Height / 2) + 100 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 800
Then x = (Screen.PrimaryScreen.Bounds.Width / 2) + 145 :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 600
Then y = (Screen.PrimaryScreen.Bounds.Height / 2) + 15 :
Me.Top = y

et en plus je ne tiens pas compte de la hauteur de la barre de tâche (cachée, simple hauteur, double hauteur, à droite etc etc) donc faudrait pouvoir connaitre la taille et la position de la barre de tâche afin de l'ajouter aux calculs de position

Merci de votre aide

@+
3
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
1 avril 2007 à 21:45
re re

et en plus faudrait tenir compte de la taille la form ...;

@+
3
42wawa42 Messages postés 143 Date d'inscription dimanche 28 septembre 2003 Statut Membre Dernière intervention 6 septembre 2011
1 avril 2007 à 21:52
Hello Didier


Ta as VB6 ou VB.Net ou autre, le quel ?


A plus sur VBFrance.com
42wawa42





<hr />
 
3
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
1 avril 2007 à 22:03
re

j'utilise Visual Studio 2005

Voilà la dernière mouture:
Dim

x
As
Integer

Dim y
As
Integer

Dim xform
As
Integer

Dim yform
As
Integer
'Taille de la formyform Me.Size.Widthxform

Me.Size.Height

'Positionnement de la Form en bas à droite en tenant compte de la barre de Tâches avec une valeur fixe

If Screen.PrimaryScreen.Bounds.Width = 1280
Then x = (Screen.PrimaryScreen.Bounds.Width) - yform :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 960
Then y = (Screen.PrimaryScreen.Bounds.Height) - xform - 65 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 1152
Then x = (Screen.PrimaryScreen.Bounds.Width) - yform :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 864
Then y = (Screen.PrimaryScreen.Bounds.Height) - xform - 65 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 1024
Then x = (Screen.PrimaryScreen.Bounds.Width) - yform :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 768
Then y = (Screen.PrimaryScreen.Bounds.Height) - xform - 65 :
Me.Top = y

If Screen.PrimaryScreen.Bounds.Width = 800
Then x = (Screen.PrimaryScreen.Bounds.Width) - yform :
Me.Left = x

If Screen.PrimaryScreen.Bounds.Height = 600
Then y = (Screen.PrimaryScreen.Bounds.Height) - xform - 65 :
Me.Top = y

Me reste plus qu'à connaitre la position de la barre de Tâches et ça taille

@+
3

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Utilisateur anonyme
1 avril 2007 à 23:02
Salut,

Pour conaitre la taille et la position de la barre de tache, il faut des apis :

<System.Runtime.InteropServices.DllImport("user32", entrypoint:="FindWindowA")> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As System.IntPtr
End Function
<System.Runtime.InteropServices.DllImport("user32", entrypoint:="GetWindowRect")> _
Private Shared Function GetWindowRect(ByVal hWnd As System.IntPtr, ByRef lpRect As System.Drawing.Rectangle) As Integer
End Function,

----

(Coloration syntaxique automatique par Kenji)



Et pour récupérer la taille :



Dim TaskBarHandle As System.IntPtr = FindWindow("Shell_TrayWnd", String.Empty)
Dim TaskBarRect As System.Drawing.Rectangle = System.Drawing.Rectangle.Empty
If Not TaskBarHandle = System.IntPtr.Zero Then GetWindowRect(TaskBarHandle, TaskBarRect),

----

(Coloration syntaxique automatique par Kenji)




__________
 Kenji
3
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
1 avril 2007 à 23:34
re manque des trucs dans la page ?????

merci de refaire et d'expliquer où tu colles tout ça précisement

merci pour tout

@+
3
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
1 avril 2007 à 23:44
re

Ok, j'ai trouvé ...me reste plus qu'à finaliser ..merci

Je donne la totale après finalisation

@+
3
cs_Didier72 Messages postés 76 Date d'inscription dimanche 10 octobre 2004 Statut Membre Dernière intervention 13 juin 2015
2 avril 2007 à 00:20
re re re re et fin...

Voilà le résultat qui permet quelque soit la taille de la form, de la résolution écran et de la position et taille de la berre de Tâches de permettre l'ouverture de ma form en bas à droite juste au sessus de la barre de Tâche et complêtement à droite le long de la fenêtre ou de la barre de Tâche s'il est à droite:

  <System.Runtime.InteropServices.DllImport("user32", entrypoint:="FindWindowA")> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As System.IntPtr
    End Function


    <System.Runtime.InteropServices.DllImport("user32", entrypoint:="GetWindowRect")> _
    Private Shared Function GetWindowRect(ByVal hWnd As System.IntPtr, ByRef lpRect As System.Drawing.Rectangle) As Integer
    End Function
 
 Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load


        Dim btx As Integer
        Dim bty As Integer
        Dim btw As Integer
        Dim bth As Integer
        Dim TaskBarHandle As System.IntPtr = FindWindow("Shell_TrayWnd", String.Empty)
        Dim TaskBarRect As System.Drawing.Rectangle = System.Drawing.Rectangle.Empty
        If Not TaskBarHandle = System.IntPtr.Zero Then GetWindowRect(TaskBarHandle, TaskBarRect)


        btx = TaskBarRect.X
        bty = TaskBarRect.Y
        btw = TaskBarRect.Width
        bth = TaskBarRect.Height
        If btx <> 0 Then btw = btx        If bty <> 0 Then bth bty : bty 0


        Dim x As Integer
        Dim y As Integer
        Dim xform As Integer
        Dim yform As Integer


        'Taille de la form
        yform = Me.Size.Width
        xform = Me.Size.Height


        'Positionnement de la Form en bas à droite en tenant compte de la barre de Tâches avec  une valeur fixe        x (btw) - yform : Me.Left x        y (bth - bty) - xform : Me.Top y
  
   End Sub
 

Merci à tous et en particulier à Charles Racaud  pour son aide précieuse ...

Super tout ça

A bientôt

  
0
Rejoignez-nous