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
| Option Explicit
Public WithEvents groupp As MSForms.Frame
Dim groupe() As New classmove
Public usf As Object
Public indexgroup As Long
Public parentgroup As Object
Dim dX As Single
Dim dY As Single
Public OF As String
Sub classegroupe(uf)
Dim ctrl As Object
indexgroup = 0
For Each ctrl In uf.Controls("ib2").Controls
If Left(ctrl.Name, 5) = "group" Then
indexgroup = indexgroup + 1: ReDim Preserve groupe(0 To indexgroup)
Set groupe(indexgroup).groupp = ctrl
Set groupe(indexgroup).usf = uf
End If
Next
End Sub
Private Sub groupp_Click()
MsgBox groupp.Name
End Sub
Private Sub groupp_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
OF = groupp.Name
dX = X
End Sub
Private Sub groupp_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim ctrl
If Button = 2 Then groupp.Move groupp.Left + (X - dX), groupp.Top
End Sub
Private Sub groupp_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim ctrl As Object, T(3000), Tbis, i
If Button = 2 Then
'mise des frames dans une variable tableaux dans l'ordre de leur position
For Each ctrl In groupp.Parent.Controls
If Left(ctrl.Name, 5) = "group" And ctrl.Left < 5 Then ctrl.Left = 1
If Left(ctrl.Name, 5) = "group" Then T(Int(ctrl.Left)) = ctrl.Name
Next
Tbis = Split(Application.Trim(Join(T, " ")))
X = 5
'deplacement des frames dans l'ordre du tableau
For i = LBound(Tbis) To UBound(Tbis)
With groupp.Parent.Controls(Tbis(i))
.Left = X + (3 * i)
X = X + .Width
End With
Next
End If
End Sub |
Partager