Private Sub hg_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
poignée_MouseMove hg, Button, X, Y
End Sub
Private Sub hd_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
poignée_MouseMove hd, Button, X, Y
End Sub
Private Sub bg_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
poignée_MouseMove bg, Button, X, Y
End Sub
Private Sub bd_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
poignée_MouseMove bd, Button, X, Y
End Sub
Private Sub poignée_MouseMove(ByVal ctrl As msforms.Control, ByVal Button As Integer, ByVal X As Long, ByVal Y As Long)
Static Dx#
Static Dy#
Dim MinRect
MinRect = 10
With ctrl
If Button = 1 Then
MinRect = MinRect * 2
If Dx = 0 Then Dx = X: Dy = X
.Move .left + (X - Dx), .top + (Y - Dy)
Select Case ctrl.Name
Case "hg":
'contrainte min top
hg.top = Application.Max(Image1.top - 10, hg.top): hd.top = hg.top
'contrainte min left
hg.left = Application.Max(Image1.left - 10, hg.left): bg.left = hg.left
'contrainte max left
hg.left = Application.Min(hg.left, hd.left - MinRect): bg.left = hg.left
'contrainte max top
hg.top = Application.Min(bg.top - MinRect, hg.top): hd.top = hg.top
'meme principe MAIS !!! inversé pour les coté opposés pour les 4
Case "hd"
hd.top = Application.Max(Image1.top - 10, hd.top): hg.top = hd.top
hd.left = Application.Min(Image1.left + Image1.width, hd.left): bd.left = hd.left
hd.left = Application.Max(hd.left, hg.left + MinRect): bd.left = hd.left
hd.top = Application.Min(bd.top - MinRect, hd.top): hg.top = hd.top
Case "bg":
bg.top = Application.Min(Image1.top + Image1.height, bg.top): bd.top = bg.top
bg.left = Application.Max(Image1.left - 10, bg.left): hg.left = bg.left
bg.left = Application.Min(bg.left, bd.left - MinRect): hg.left = bg.left
bg.top = Application.Max(bg.top, hg.top + MinRect): bd.top = bg.top
Case "bd"
bd.top = Application.Min(Image1.top + Image1.height, bd.top): bg.top = bd.top
bd.left = Application.Min(Image1.left + Image1.width, bd.left): hd.left = bd.left
bd.left = Application.Max(bd.left, bg.left + MinRect): hd.left = bd.left
bd.top = Application.Max(bd.top, hd.top + MinRect): bg.top = bd.top
End Select
calque.Move hg.left + 10, hg.top + 10, hd.left - hg.left - 10, bg.top - hg.top - 10
Else
Dx = 0: Dy = 0
End If
End With
End Sub