hidrau
asked on
question about release
Hello Guys
I would like to understand this:
Form := Tform.Create(Application);
Form.showmodal;
Form.Release
well, after a showmodal I destroyed my form with release, if I test if Form is like nil, why isn't it nill?
Thanks
I would like to understand this:
Form := Tform.Create(Application);
Form.showmodal;
Form.Release
well, after a showmodal I destroyed my form with release, if I test if Form is like nil, why isn't it nill?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh, and docs say it's recommended not to use release, but free ;)
>oh, and docs say it's recommended not to use release, but free ;)
you mean vice versa -> it's recommended to use release
because -> read online help -> keyword release
meikl ;-)
you mean vice versa -> it's recommended to use release
because -> read online help -> keyword release
meikl ;-)
ASKER
ciuly, in my project, I am using to destroy all forms release, do you think I can have any problem with release.
meikl, you are right :) for the form, indeed release is the one to be called. thought for the rest of teh components, it's free since release does not exist.
confusion from my part. sorry :)
hidrau, answering your question directly (though meikl responded, so I only emphasis what he said): no problems with release. it is release you should use to destroy a form. using any other method will porbably cause problems (as stated in the docs)
sorry again for the confusion I created.
confusion from my part. sorry :)
hidrau, answering your question directly (though meikl responded, so I only emphasis what he said): no problems with release. it is release you should use to destroy a form. using any other method will porbably cause problems (as stated in the docs)
sorry again for the confusion I created.
ASKER
no problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>Release does eventually free the object...
not eventually, it does free the object ;-)
btw. the action caFree calls internal also the release method
meikl ;-)
not eventually, it does free the object ;-)
btw. the action caFree calls internal also the release method
meikl ;-)
Now lets not muddy the water...
It is eventually...it uses PostMessage which just puts the message on the queue... which unlike Free which runs the code immediately...Release allows the Form the chance to notify anybody who cares...and let them finish up cleaning up...
procedure TCustomForm.Release;
begin
PostMessage(Handle, CM_RELEASE, 0, 0);
end;
procedure TCustomForm.CMRelease;
begin
Free;
end;
It is eventually...it uses PostMessage which just puts the message on the queue... which unlike Free which runs the code immediately...Release allows the Form the chance to notify anybody who cares...and let them finish up cleaning up...
procedure TCustomForm.Release;
begin
PostMessage(Handle, CM_RELEASE, 0, 0);
end;
procedure TCustomForm.CMRelease;
begin
Free;
end;