Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Won't release the form
Message
From
10/08/2001 06:55:54
 
 
To
10/08/2001 06:51:10
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00542159
Message ID:
00542193
Views:
25
Hi!

Correct.

However, I just looked to all this: when you work with the forms only, why not use _Screen.FormCount and _Screen.Forms collection? Well, there are certain cases when forms manager object is needed anyway, for example, when you open the same form many times and have meny instances. In such case manager can help to separate them by unique internal name...


>>Hi!
>>
>>>>Hi!
>>>>
>>>>Let say, goRefMgr is a public variable holding the object responsible for managing cross-references in your applicatiosn. When you release certain object that you know could be referenced elsewhere in your application, in the Destroy event of that object call goRefMgr.GoingToDestroy(this), for example. As you see, you pass a reference to method. In the method:
>>>>
>>>>
>>>>lparameters poObject
>>>>...
>>>>for i=1 to alen(this.aReferences,1) &&  aReferences hold all references to objects
>>>>  if poObject = this.aReferences[i] && compare 2 object references...
>>>>    this.aReferences[i] = ''
>>>>    adel(...)
>>>>  endif
>>>>endfor
>>>>
>>>>
>>>>I also do not know if ASCAN will work for object references, but you can try.
>>>>
>>>>Without generic approach and some kind of concept related to objects referencing you will get a lot of situations when form or certain object do not release from memory, and it will be hard to figure out all places with such references. Doing referencing through some kind of centralized tool (references manager) will h elp you to track all of them.
>>>>
>>>>HTH.
>>>>
>>>>>>Hi!
>>>>>>
>>>>>>No. Just before releasing object you have to clear these references. So you require to establish both way referencing - when you hold object reference, that object should know about that for case it is gonna to destroy self and know what to clear. Well, you can use public variables for that, but this is not a good thing. Better use some sort of manager object that will hold a collection of object references. You can than find your object in that collection by simple compare of references - object references are correctly comparable in VFP.
>>>>>
>>>>>Vlad
>>>>>
>>>>>Sorry for sounding a bit thick here, but how can I compare the object references in the manager?
>>>>>
>>>>>Kev
>>>Vlad
>>>
>>>If I had a Main toolbar that fired of functions in various forms, would the RefMgr be used then?
>>>
>>
>>I guess yes. Toolbar is the object in the memory, the same as form and goRefMgr ;) Just create such object and use its methods to manage references. Say, you can from toolbar call its method "GetObjRef('ObjectName')".
>>
>>oMyForm = GetObjRef('CustomersForm')
>>
>>References manager searches through objects and return the reference or NULL if such object already released or do nto exists. Using that reference you can call functions of forms. Of course, you have to add also AddReference() method to manager and RemoveReference. Maybe somethign else, if needed - let see and figure out depended on the logic of your program.
>
>Thanks Vlad
>
>Between your message I knocked up a class that has UpdateRef() and GetCurrentForm() etc. etc and have created an array property called aFormRef(1).
>
>Is that the sort of thing you mean? you see within my app object, it looks at the "currently active" form and carrys out certain checks on the form, so i think the refmgr would be the best bet.
>
>When the app closes, do I need to clear all object references in the manager by doing an adel() or by doing a aFormRef(nReference).Release() or by some other way.
>
>Thanks
>Kev
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform