Is there a way to get at runtime the Object inheriting class instances added to a window in the IDE?
As an example: Timer is not inheriting from Control but from Object, so when looping over all controls like that:
For i As Integer = 0 To win.ControlCount - 1
...
Next
… the timer is not found because it doesn’t inherit from Control.
My current solution is a bit clumsy and not too fast (this code is in the open event of a window subclass):
Dim oi As Runtime.ObjectIterator = Runtime.IterateObjects()
Do Until Not oi.MoveNext()
Dim ti As Introspection.TypeInfo = Introspection.GetType(oi.Current)
Dim pis() As Introspection.PropertyInfo = ti.GetProperties()
For Each pi As Introspection.PropertyInfo In pis
If pi.Name = "ownerWindow" Then // ownerWindow is not documented, so not future-proof
If pi.Value(oi.Current) = Self Then
// oi.Current is an Object added to this window in the IDE
End
End
Next
Loop
Is there a simpler way?