When the sub form closes, only the controls on the sub form are freed for
example

 

In form 1 I have myedit : tedit; // my own declaration;

i create a form 2 which I drop an edit box (it will be automatically names
edit1)

 

so on form 1 I do; myedit = form2.edit1;

I can manipulate the contents of the edit on form 2 by either using
form1.edit1.text:='jangita' or I can use myedit.text:='jangita';

This is because these variables are actually pointers and point to the same
component in memory.

 

When I close form2; the edit box is automatically freed (it sits on form2
and form2 is the owner)

 

So any reference weather is using myedit.text:='hello' or
form2.edit2.text:='hello' will raise an access violation exception.

 

So to your question if you free form2; then the assignment is invalid.

 

Hope it helps .

 

J

 

PO Box 627 00502 Karen, 
Nairobi, Kenya.
Mobile: +254 722 996532
Fixed: +254 20 2050859
[EMAIL PROTECTED] 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of edsynergy
Sent: 23 January 2008 1:28 p
To: [email protected]
Subject: [delphi-en] Re: Assigning object

 

J, no problem with subform, its really about the assignment of edit1
on the mainform. 

edit1 on the mainform is just a declaration of a Tedit, its not
actually on the form.

My concern is what happens to it when the subform closes.

Ed..

--- In [EMAIL PROTECTED] <mailto:delphi-en%40yahoogroups.com> ps.com,
"Jangita" <[EMAIL PROTECTED]> wrote:
>
> Ed,
> 
> 
> 
> Are these declarations created by Delphi or are you the one who has
put them
> into the code manually?
> 
> From what I have read; if you close the sub form its tedit (the one
on the
> sub form) is deallocated automatic because when you drop a control
onto a
> form its owner property is the parent control (be it a form or a
panel) so
> when the form is freed or destroyed it automatically frees all the
> components and their "dependants" with it. This is true weather you have
> assigned its variable (in code) to another control or not.
> 
> 
> 
> Maybe if you explain what you want to achieve with this?
> 
> 
> 
> J
> 
> 
> 
> PO Box 627 00502 Karen, 
> 
> Nairobi, Kenya.
> 
> Mobile: +254 722 996532
> 
> Fixed: +254 20 2050859
> 
> [EMAIL PROTECTED]
> 
> 
> 
> _____ 
> 
> From: [EMAIL PROTECTED] <mailto:delphi-en%40yahoogroups.com> ps.com
[mailto:[EMAIL PROTECTED] <mailto:delphi-en%40yahoogroups.com> ps.com]
On Behalf
> Of edsynergy
> Sent: 23 January 2008 1:14 p
> To: [EMAIL PROTECTED] <mailto:delphi-en%40yahoogroups.com> ps.com
> Subject: [delphi-en] Assigning object
> 
> 
> 
> 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; 
> 
> When I close the subform what happens to edit1 on the mainform ?
> Is it automatically unassigned, if not does it get cleaned up when the
> main form closes.
> 
> Should I in the onclose event of the subform do mainform.edit1 := nil;
> 
> All advice welcome
> 
> Best wishes Ed.
> 
> 
> 
> 
> 
> [Non-text portions of this message have been removed]
>

 



[Non-text portions of this message have been removed]

Reply via email to