Meilleur auteur de réponses
Comment trouver la position et les dimensions d'une fenetre "explorateur windows"

Question
-
Vb2008
Bonjour,
j'ai besoin d'ouvrir 2 fenêtres "explorateur windows" positionnées cote à cote .
j'utilise la classe "process" pour les ouvrir.
Comment retrouver les caractèristques géométriques d'un fenetre d'après son process ID.
Merci d'avance pour votre aide
JJK
Réponses
-
Bonjour,
Il vous faudra utiliser la fonction GetWindowsRect de l'API User32.
Voici un exemple d'utilisation :
<DllImport("user32.dll")> _ Private Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lprect As RECT) As Boolean End Function <StructLayout(LayoutKind.Sequential)> _ Public Structure RECT Public X As Integer Public Y As Integer Public Right As Integer Public Bottom As Integer Public ReadOnly Property Width() As Integer Get Return Right - X End Get End Property Public ReadOnly Property Height() As Integer Get Return Bottom - Y End Get End Property End Structure
Maintenant je veux créer un process (Notepad pour faire simpe et obtenir ses coordonnées :
Dim myNotepad As New Process() myNotepad.StartInfo.FileName = "Notepad" myNotepad.Start() System.Threading.Thread.Sleep(2000) Dim handle As IntPtr = myNotepad.Handle Dim coordinateNotepad As New RECT() GetWindowRect(handle, coordinateNotepad) Console.WriteLine(coordinateNotepad.X.ToString()) Console.WriteLine(coordinateNotepad.Y.ToString())
J'espère que cela vous aidera.
Cordialement,
Mathieu
Mathieu Francesch Sharplog Engineering- Proposé comme réponse Mathieu Francesch lundi 11 janvier 2010 01:05
- Marqué comme réponse Mathieu Francesch jeudi 11 février 2010 09:59
Toutes les réponses
-
Bonjour,
Il vous faudra utiliser la fonction GetWindowsRect de l'API User32.
Voici un exemple d'utilisation :
<DllImport("user32.dll")> _ Private Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lprect As RECT) As Boolean End Function <StructLayout(LayoutKind.Sequential)> _ Public Structure RECT Public X As Integer Public Y As Integer Public Right As Integer Public Bottom As Integer Public ReadOnly Property Width() As Integer Get Return Right - X End Get End Property Public ReadOnly Property Height() As Integer Get Return Bottom - Y End Get End Property End Structure
Maintenant je veux créer un process (Notepad pour faire simpe et obtenir ses coordonnées :
Dim myNotepad As New Process() myNotepad.StartInfo.FileName = "Notepad" myNotepad.Start() System.Threading.Thread.Sleep(2000) Dim handle As IntPtr = myNotepad.Handle Dim coordinateNotepad As New RECT() GetWindowRect(handle, coordinateNotepad) Console.WriteLine(coordinateNotepad.X.ToString()) Console.WriteLine(coordinateNotepad.Y.ToString())
J'espère que cela vous aidera.
Cordialement,
Mathieu
Mathieu Francesch Sharplog Engineering- Proposé comme réponse Mathieu Francesch lundi 11 janvier 2010 01:05
- Marqué comme réponse Mathieu Francesch jeudi 11 février 2010 09:59
-
bonjour,
Est ce que votre problème a été résolu ?
Cordialement,
Mathieu
Mathieu Francesch Sharplog Engineering