Home |
Deleting/Removing PegThings Obtaining a Pointer to PegPresentationManager Determining the Position of an Object |
Deleting/Removing PegThingsRemoving a PegThing (i.e. a window, button, dialog, or other object derived from PegThing) from its parent is not the same as deleting it. Removing an object takes it out of the active display tree. After being removed, the object no longer has a parent, and it will not be visible. It is possible, even common, to later re-add the object to a visible PegThing and use it over again. A PegThing is removed by calling the PegThing member function Remove(PegThing * What). It doesn't matter if the parent object removes a child, or if a child removes itself, because the Remove() function properly handles either case. That is, it is perfectly acceptable to use the following statement: Remove(this); when an object decides based on some message input that it is time to go away. While Remove() can be useful, it is more common to want to both remove the object from its parent, as well as delete the object from memory. There are three acceptable ways to remove and delete an object:
One should never execute delete(this). When in doubt, it is always safe to call Destroy(). It is not necessary to manually delete the individual children of a PegThing, in fact it will cause errors if this is attempted. Obtaining a Pointer to PegPresentationManager
|