Information générale
Titre:
Finally !! How to safely release objects in a Control Array
I discover how to deal with control arrays, and get rid of them in a safe way:
If you create an array property in your form, i.e.
THISFORM.aObjs[1]
and then redimension the array for adding objects with AddObject(), i.e.
DIMENSION THISFORM.aObjs[3]
THISFORM.AddObject("THISFORM.aObjs[1]","CommandButton")
THISFORM.AddObject("THISFORM.aObjs[2]","CommandButton")
THISFORM.AddObject("THISFORM.aObjs[3]","CommandButton")
The code for releasing those objects, acording to MS, is doing a redimension to the array. But you can't set the array to 0 objects !!. And, with the command DIMENSION THIS.aObjs[1], you are just releasing 2 objects. If you store a .NULL. in the element 1, you are NOT releasing the object 1.
And sometimes, when you try to release the form, it won't close.
To avoid this, ALWAYS add the objects beginning at the element 2. Then, to release the objects, just redimension the array back to 1 element.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement