Thank you very much Ken for your time.
Vassilis
----- Original Message -----
From: "Ken Dibble" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 09, 2007 3:30 AM
Subject: Re: Why I can't delete a container object from another container?
>
>>1. I have a container class based on native foxpro container class
>>2. I create another container class based on native foxpro container class
>>and I add the previous container object and a native commandbutton.
>>3. In the click event of the command button I write:
>> This.Parent.RemoveObject("acontainer1")
>> WAIT WINDOW VARTYPE(This.Parent.acontainer1)
>>
>>4. I Create a new form and I add the second container object.
>>5. Running the form and clicking on the button after "removing" the
>>aContainer1 the vartype returns "O"!
>>
>>Does anybody know something about this?
>
> Based on your description above, I concocted some sample code. However,
> that code throws an error. I also prepared two alternate versions, one of
> which behaves strangely in my opinion, but neither of which exhibits the
> problem you observed. These were all tested in VFP 7 SP 1.
>
> Code follows signature.
>
> Ken Dibble
> www.stic-cil.org
>
> *** Code as I derived from your message ***
> PUBLIC oForm
>
> oForm = CREATEOBJECT("Form")
>
> oForm.AddObject("acontainer1","ContainerTwo")
>
> oForm.acontainer1.Visible = .T.
>
> oForm.Show()
>
> DEFINE CLASS ContainerOne AS Container
>
> ENDDEFINE
>
> DEFINE CLASS ContainerTwo AS Container
> ADD OBJECT Mycontainer AS ContainerOne
> ADD OBJECT MyCmd AS TestCommand
> ENDDEFINE
>
> DEFINE CLASS TestCommand AS CommandButton
> PROCEDURE Click
> * "Unknown member acontainer1", as expected,
> * because the parent IS acontainer1.
> THIS.Parent.RemoveObject("acontainer1")
>
> WAIT WINDOW VARTYPE(THIS.Parent.acontainer1)
> ENDPROC
> ENDDEFINE
> *** END CODE ***
>
> *** ALTERNATE SCENARIO 1 ***
> PUBLIC oForm
>
> oForm = CREATEOBJECT("Form")
>
> oForm.AddObject("acontainer1","ContainerTwo")
>
> oForm.acontainer1.Visible = .T.
>
> oForm.Show()
>
> DEFINE CLASS ContainerOne AS Container
>
> ENDDEFINE
>
> DEFINE CLASS ContainerTwo AS Container
> ADD OBJECT Mycontainer AS ContainerOne
> ADD OBJECT MyCmd AS TestCommand
> ENDDEFINE
>
> DEFINE CLASS TestCommand AS CommandButton
> PROCEDURE Click
> THIS.Parent.RemoveObject("Mycontainer")
>
> * Outputs "U". However, I don't understand
> * why this works, because you should not be
> * able to remove a member of a class in an
> * instance of that class.
> WAIT WINDOW VARTYPE(THIS.Parent.acontainer1)
> ENDPROC
> ENDDEFINE
> *** END CODE ***
>
> *** ALTERNATE SCENARIO 2 ***
> PUBLIC oForm
>
> oForm = CREATEOBJECT("Form")
>
> oForm.AddObject("acontainer1","ContainerTwo")
>
> oForm.acontainer1.Visible = .T.
>
> oForm.Show()
>
> DEFINE CLASS ContainerOne AS Container
>
> ENDDEFINE
>
> DEFINE CLASS ContainerTwo AS Container
> ADD OBJECT Mycontainer AS ContainerOne
> ADD OBJECT MyCmd AS TestCommand
> ENDDEFINE
>
> DEFINE CLASS TestCommand AS CommandButton
> PROCEDURE Click
> THISFORM.RemoveObject("acontainer1")
>
> * Outputs "U" and everything disappears off
> * the form. This is what I expect.
> WAIT WINDOW VARTYPE(THIS.Parent.acontainer1)
> ENDPROC
> ENDDEFINE
> *** END CODE ***
>
>
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.