Re:MDI-Child Form not set to nil after Closed
Freeing the object and niling the variable(s) pointing to that object are two
seperate operations. If you want to have only one instance and that instance
will always point to the Child variable then set the Child variable to nil in
the OnClose event also. Be vary careful that all variables that point to that
instance are nil'd out. Usually it is better to rely on FindComponent passing
the name of the form to the MDI Parent if that returns nil then the form does
not exist otherwise it will return the form instance. Something like
if FindComponent('Form2') = nil then
TForm2.Create(self).Show;
Remember that more than one variable can point to the Object. An object does
not keep track of who all points to it so it can not nil out those variables
when it gets freed.
Quote
Synetrum wrote:
> In my OnClose event handler methode, I've set the parameter CloseAction to
> caFree. In my main form, I check if the child exist (if Assigned(Child) then
> ...) before creating and using it. I was surprised to see that after closing
> the child, it wasn't set to nil: so the main form doesn't create it and it
> result in an exception. What I'm doing wrong ??
> Thanks.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpetted corridors of Whitehall.
(Fish)
--