- Код: Выделить всё
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
BuddyControl = PropBag.ReadProperty("BuddyControl", "")
End Sub
Public Property Let BuddyControl(ByVal New_Buddy As String)
Dim k As Collection
Dim i As Integer
Set k = BuddyControls
For i = 1 To k.Count
If LCase$(New_Buddy) = LCase$(k(i)) Then
m_BuddyControl = k(i)
PropertyChanged "BuddyControl"
Exit Property
End If
Next i
End Property
Friend Property Get BuddyControls() As Collection
Dim sMyName As String
Dim c As Control
Dim sTmp As String
Dim ihWnd As Long
sMyName = Ambient.DisplayName
Set BuddyControls = New Collection
For Each c In UserControl.Parent.Controls
sTmp = c.Name
If (TypeName(UserControl.Parent.Controls(sTmp)) = "Object") Then
sTmp = c.Name & "(" & c.Index & ")"
End If
If sTmp <> sMyName Then
ihWnd = Try(c)
If ihWnd <> 0 Then
BuddyControls.Add sTmp
End If
End If
Next c
End Property
Private Function Try(ByVal iObj As Object) As Long
On Error Resume Next
Try = iObj.hWnd
End Function
Спасибо.