' Le type RECT
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type POINTAPI
X As Long
Y As Long
End Type
' Le placement d'une fenetre
Public Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpWndPl As WINDOWPLACEMENT) As Long
Public Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpWndPl As WINDOWPLACEMENT) As Long
Public Type WINDOWPLACEMENT
Length As Long
Flags As Long
ShowCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWNOACTIVATE = 4
'---------------------------------------------------------------------------------------
' Procedure : GetWindowPosition
' DateTime : 23/12/2006 19:35
' Author : Vb System Library
' Purpose : Renvoie la position de la fenetre sous forme de type Rect
' Params : hWnd : Handle de la fenetre
'---------------------------------------------------------------------------------------
Public Function GetWindowPosition(ByVal hWnd As Long) As RECT
Dim tmpRect As RECT
GetWindowRect hWnd, tmpRect
GetWindowPosition = tmpRect
End Function
'---------------------------------------------------------------------------------------
' Procedure : SetWindowPosition
' DateTime : 23/12/2006 19:35
' Author : Vb System Library
' Purpose : Renvoie la position de la fenetre sous forme de type Rect
' Params : hWnd : Handle de la fenetre
'---------------------------------------------------------------------------------------
Public Function SetWindowPosition(ByVal hWnd As Long, Optional ByVal Left As Variant, Optional Top As Variant, Optional Width As Variant, Optional Height As Variant)
Dim WndPl As WINDOWPLACEMENT
WndPl.Length = Len(WndPl)
GetWindowPlacement hWnd, WndPl
If (Not IsMissing(Left)) And IsNumeric(Left) Then
WndPl.rcNormalPosition.Right = WndPl.rcNormalPosition.Right - WndPl.rcNormalPosition.Left + Left
WndPl.rcNormalPosition.Left = Left
End If
If (Not IsMissing(Top)) And IsNumeric(Top) Then
WndPl.rcNormalPosition.Bottom = WndPl.rcNormalPosition.Bottom - WndPl.rcNormalPosition.Top + Top
WndPl.rcNormalPosition.Top = Top
End If
If (Not IsMissing(Width)) And IsNumeric(Width) Then WndPl.rcNormalPosition.Right = WndPl.rcNormalPosition.Left + Width
If (Not IsMissing(Height)) And IsNumeric(Height) Then WndPl.rcNormalPosition.Bottom = WndPl.rcNormalPosition.Top + Height
SetWindowPlacement hWnd, WndPl
End Function
Le 30/12/2006 par MadMatt : Legere modif
Seul les admins et l'auteur du code lui même peuvent modifier ce code.