Control / ControlCount

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?

A simpler way would be to not add the Timer to the window in the Layout Editor. Instead, instantiate the Timer in code and then track it yourself.

Thanks Paul, but - as I mentioned - the timer is just an example.

I would like to generalize something in a window subclass. It is working with Runtime.ObjectIterator - I just want to know if there is an easier (and faster) way to do it.

Sorry, I scanned it too quickly!

I can’t think of anything else offhand.