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
| 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 oldposition As Long
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)
dX = X: oldposition = groupp.Left
End Sub
Private Sub groupp_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
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 f As Object, Ctrl As Object, L&
If Button = 2 Then
For Each Ctrl In groupp.Parent.Controls
If Left(Ctrl.Name, 5) = "group" And Ctrl.Left < groupp.Left Then
L = Ctrl.Left: Set f = Ctrl
End If
Next
If Not f Is Nothing Then f.Left = oldposition: groupp.Left = L Else groupp.Left = oldposition
End If
End Sub |
Partager