cs_Didier72
Messages postés76Date d'inscriptiondimanche 10 octobre 2004StatutMembreDernière intervention13 juin 2015
-
1 avril 2007 à 20:41
cs_Didier72
Messages postés76Date d'inscriptiondimanche 10 octobre 2004StatutMembreDernière intervention13 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 ?
cs_Didier72
Messages postés76Date d'inscriptiondimanche 10 octobre 2004StatutMembreDernière intervention13 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
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),
cs_Didier72
Messages postés76Date d'inscriptiondimanche 10 octobre 2004StatutMembreDernière intervention13 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 ...