1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
   | Private Type POINTAPI
        X As Long
        y As Long
End Type
Private Type RECT
        Bottom As Long
        Left As Long
        Right As Long
        Top As Long
End Type
Private Type WINDOWPLACEMENT
        flags As Long
        Length As Long
        ptMaxPosition As POINTAPI
        ptMinPosition As POINTAPI
        rcNormalPosition As RECT
        showCmd As Long
End Type
Private Declare Function GetWindowPlacement Lib "user32" ( _
    ByVal Hwnd As Long, _
    lpwndpl As WINDOWPLACEMENT) As Long
 
Private Declare Function MoveWindow Lib "user32" ( _
    ByVal Hwnd As Long, _
    ByVal X As Long, _
    ByVal y As Long, _
    ByVal nWidth As Long, _
    ByVal nHeight As Long, _
    ByVal bRepaint As Long) As Long
Public FMeCoord As WINDOWPLACEMENT
 
Private Type LesCoord
        Height As Long
        Left As Long
        Top As Long
        Width As Long
End Type
 
Public MeCoord As LesCoord
 
'******************************************************************
'** la propriété ScaleMode de UserControl doit être mis à Pixels **
'** la propriété KeyPreview de UserControl doit être mis à True  **
'******************************************************************
 
Public Sub GetPlace(Hwnd As Long)
    'recuperation des coordonnées de l'UserControl posé sur le conteneur
    GetWindowPlacement Hwnd, FMeCoord
 
MeCoord.Height = FMeCoord.showCmd - FMeCoord.rcNormalPosition.Right
MeCoord.Left = FMeCoord.rcNormalPosition.Left
MeCoord.Top = FMeCoord.rcNormalPosition.Right
MeCoord.Width = FMeCoord.rcNormalPosition.Top - FMeCoord.rcNormalPosition.Left
End Sub | 
Partager