O/H edsynergy έγραψε:
>
>
> Ok ,
> I have a main form and several sub forms that get called from the main
> form
>
> In the public of the main form I could have something like this
> edit1:Tedit;
>
> In my subform I have a Tedit on the form
>
> In my subform I do this mainform.edit1 := subform Tedit;
mainform.edit1 := subform Tedit; // this is not a legal Pascal code
>
> When I close the subform what happens to edit1 on the mainform ?
Nothing :)
The Edit1 of the SubForm is destroyed when SubForm is destroyed,
if the Edit1 is just dropped on the SubForm at design time.
That is SubForm destroys any component it owns.
The Edit1 reference of the MainForm still points to where
SubForm's Edit1 was in memory. But this memory now is not a valid TEdit
instance. SubForm's Edit1 is gone.
In other words, MainForm's Edit1 points to an invalid pointer.
> Is it automatically unassigned, if not does it get cleaned up when the
> main form closes.
Is this a question?
If it is, I'm not sure I fully understand what is asking.
When a main form closes, it automatically terminates the application
and the main form is destroyed. When a form is destroyed, destroys
any component it owns, just as any other component does as an owner.
> Should I in the onclose event of the subform do mainform.edit1 := nil;
Of course. Otherwise your MainForm's Edit1 public field
points to an invalid instance of a TEdit class.
if not Application.Terminated then
MainForm.Edit1 := nil;
Theo
PS. Please camelize the code snippets you post.
i.e. MainForm.Edit1 := SubForm.Edit1;
--
Regards
Theo
------------------------
Theo Bebekis
Thessaloniki, Greece
------------------------
Greek_Delphi_Prog : a Delphi Programming mailing list in Greek at
http://groups.yahoo.com/group/Greek_Delphi_Prog
CSharpDotNetGreek : A C# and .Net mailing list in Greek language at
http://groups.yahoo.com/group/CSharpDotNetGreek
atla_custom : a Unisoft Atlantis Customization mailing list at
http://groups.yahoo.com/group/atla_custom
------------------------
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/delphi-en/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/