The first part of which is about about what turned to be simple, but the second thing was that I needed to walk the control hierarchy (which could contain ContainerControls) to see if any parent (including the container controls) implement a specific class interface.
Of course the simple obvious way does not work… But i found a way to do it without using Norm’s method of searching the runtime using RectControl.Window for which isA works as expected for this purpose.
Tim Hare responded that for this specific case using RectControl.Window works, but more generally one has to search the runtime…
In real world usage, as the cases where a ContainerControl does not have at least one RectControl on it would be very small (if any!), in what cases would this method not work?
Tim replied on the TOF but I figured out how to solve the problem another way besides searching the Runtime:
When I posted the previous message I was thinking there was way to get a reference to RectControl on the ContainerControl but when you have it as an EmbeddedWindowControl there is no direct way…
But what i was trying to do lends itself to another , admittedly a bit convoluted, way to get a reference to it AS a ContainerControl Or as a Window without having to iterate the runtime, which could be expensive in a large project.
Create a ClassInterface
Method RegisterContainer( theContainer As ContainerControl)
Have the window (or any RectControl in the hierarchy using my code above to walk it if needed) implement it.
Subclass ContainerControl (so you can make any ContainerControl work this way by just changing it’s super)
3a) In it’s Open event you do:
If me.Window IsA ContainerControlHolder Then
Now the window has a reference to the ContainerControls as a container control
If you want it as a window, in the open event find it’s first RectControl and use it to get RectControl.Window instead and return that (changing the types to Window of course)
From Inside the embedded container control event in your subclass you have access to all the CC window methods/properties…
While the code is not so neatly packaged in a single method , this may be a better way than searching the Runtime.
I’ve had need to do roughly what you do in the second post here but I used a different mechanism and it tracks every last control regardless of how its added (at design time, programmatically at runtime) regardless of what kind of control it is.