Question

HI

I have an application with more than one frame that act as forms.

I have temporary files I need to delete when the user moves from a certain frame and I currently delete the file when they press OK or CANCEL.

If they just close the application I also want to delete the temporary files but cannot determine when the frame is destroyed.

Regards, Pieter

Was it helpful?

Solution

To detect when a frame is destroyed, override its destructor, Destroy.

If overriding the destructor is not appropriate (say, if the files belong to the enclosing form rather than the frame), then you can use component notification. After you create the frame, call its FreeNotification method, passing in a reference to the enclosing form. When the frame is destroyed, it will call the form's Notification method. Override that method in your form, and if the component is the frame, delete the files. (That method may be called many times in your program, so checking the AComponent parameter is important.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top