Re: Problem freeing components with .free
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 15 Feb 2007 04:45:53 -0800
On Feb 14, 8:13�pm, "TeChNoInSiDe" <tomatin...@xxxxxxxxx> wrote:
Delphi help says:
FREE Method
"Never explicitly free a component within one of its own event
handlers or the event handler of a component it owns or contains. For
example, don't free a button, or the form that owns the button, in its
OnClick event handler."
----------------------------------------------------------------------------------------
In my form I have a image listing section, a save button and a
SaveImages() function associated with save button's onclick handler.
SaveImages() do some saving operations and then destroys (with .free
method) images and the save button. As said in delphi warning, i am
getting access violation after freeing the save button.
I tried to make a SaveButtonHandler for onclick handler and inside it
calling the SaveImages function but seems it has the same effect.
I created a threaded timer and activated it on savebuttonhandler and
then called saveimages() on timer event. This worked great but lead me
to another programming limitations (because of a isolated thread
process).
So, does anybody know any workaround for using .free on this
situation, without using timers?
Have the button OnClick Post a private message to your form as the
last line of code in the handler.
When your form receives that message then free the button.
Alan Lloyd
.
- Follow-Ups:
- Re: Problem freeing components with .free
- From: TeChNoInSiDe
- Re: Problem freeing components with .free
- References:
- Problem freeing components with .free
- From: TeChNoInSiDe
- Problem freeing components with .free
- Prev by Date: Re: Problem freeing components with .free
- Next by Date: Re: Problem freeing components with .free
- Previous by thread: Re: Problem freeing components with .free
- Next by thread: Re: Problem freeing components with .free
- Index(es):