Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing form while references to contols exist
Message
From
26/06/1998 17:25:27
 
 
To
26/06/1998 16:26:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00112066
Message ID:
00112085
Views:
19
I have an object that dynamically creates headers for list boxes. This object is placed on a form, and a property (pcListBoxName) is set to be the name of the list box to manage.

The object also has a property that is an object reference to the same list box (EVAL(pcListBoxName)). My problem is that the form will not release. I think I understand what is happening: the form release sees that there is a reference to one of the controls on the form (the list box), and therefore refuses to destroy itself.

I can code around this several ways (like by not keeping that object reference and EVALing everywhere, or specifically calling destroy() of the class with the reference), but it seems like there should be a better way.

Hi Robert,

You are going to have to explicitly destry the object referenced by your header management object. Presumably the reference object has some sort of name, i.e.
              oListBox = EVALUATE(pcListBoxName)
<\pre>
so somewhere in the events that release the form, oListBox is going to have to be set to .NULL. or 0 (zero) or something other than a reference to an object -- the traditional setting is to .NULL.

You can do this in the destroy() or unload() events of the form,
<PRE>
              this.myHeaderControlObject.oListBox = .NULL.
or, as I often do, in the click() event of the button that releases the form.

Another option would be to make oListBox local to the method in myHeaderControlObject that manipulates it. That way it will automatically be destroyed when your return from the method and it goes out of scope, i.e.
              LOCAL loListBox
              loListBox = EVALUATE(pcListBoxName)
              *-- do stuff
              RETURN
              *-- bye, bye loListBox
Even if loListBox is used by several methods of the header control object, it may be possible just to pass it to other objects as an argument and catch it in a local LPARAMETER statement.

Lastly, what is the possibility that the header control object can just set oListBox to .NULL. when it returns from the last method to be invoked?

Regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform