Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Members of a parent class cannot be deleted
Message
From
05/02/2008 04:47:22
 
 
To
23/01/2008 08:24:56
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01282237
Message ID:
01289449
Views:
19
>>>If I have MyForm based on a class, and the class has an object on it, why am I not able to delete the object from MyForm? I have to hide it by moving it off the screen or something like that. I'm sure there is some class rule about it, but it seems that if I don't want part of something from the parent on MyForm, I should just be able to remove it.
>>
>>
>>member.Init
>>RETURN .F.
>>
>>
>>Removeobject doesn't remove the member name property.
>
>I like this solution, but could you explain a bit more about the last sentence?

If you apply object.Removeobject("classmember") to a class's member,
VFP remove the "classmember" member object,
but leave the "classmember" property into the someobject into a wrong State.
someObject = CREATEOBJECT("SOMECLASS")
CLEAR

ON ERROR ? MESSAGE()

test()

?
? "************* RemoveObject **********", m.someObject.RemoveObject("SomeMember")
?

test()

DEFINE CLASS SOMECLASS AS CONTAINER
	
	ADD OBJECT SomeMember AS CONTAINER
	
ENDDEFINE

PROCEDURE test
? PEMSTATUS(m.someObject,"SomeMember",3), m.someObject.SomeMember
? ISNULL(m.someObject.SomeMember)
? m.someObject.ControlCount, m.someObject.objects.Count
? m.someObject.SomeMember.Name
But this is true even using Return. F. into the SomeMember.Init.
someObject = CREATEOBJECT("SOMECLASS")
CLEAR

ON ERROR ? MESSAGE()

test()

DEFINE CLASS SOMECLASS AS CONTAINER
	
	ADD OBJECT SomeMember AS CONTAINER
	
	PROCEDURE SomeMember.INIT
		RETURN .f.
	
ENDDEFINE

PROCEDURE test
? PEMSTATUS(m.someObject,"SomeMember",3), m.someObject.SomeMember
? ISNULL(m.someObject.SomeMember)
? m.someObject.ControlCount, m.someObject.objects.Count
? m.someObject.SomeMember.Name
Then, the only solution without side effects is to use AddObject("SomeMember").
Previous
Reply
Map
View

Click here to load this message in the networking platform