ContainerControl and ParentWindow question

I know how to do this with a separate window, but trying it with a ContainerControl puzzles me:

I need to set up a lot of parameters which are window specific. To do this I create a window winSettings and pass the calling window mainWindow as parameter:

dim w as new winSettings( self ) w.showModalWithin( self )

I’m trying something similar with a ContainerControl (mainly to be able to control how the settings dialog appears, e.g. sliding in from the side etc).
I add a property ParentWindow as mainWindow. I add a Constructor to the ContainerControl with

ParentWindow = mainWindow( self.TrueWindow )

I tried several variations but I always get an error (usually Nil exception, but also stack overflow depending on the variation)

Why does ParentWindow = mainWindow( self.TrueWindow ) give me a Nil Object Exception?

Does the enclosing window not exist yet when the ContainerControl is constructed?

AFAIK this is correct. The order is:

Constructor of all controls (includes ContainerControl instances) Constructor of the window Open event of all controls (includes ContainerControl instances) Open event of the window

Thanks Eli. Will stick with a Canvas then to do the sliding …

You can also initialize ContainerControl.ParentWindow in the window Open event. Or use a timer…

I was thinking of that too, but problem is then that several of the controls on the ContainerControl refer to the Parent window in THEIR open event.