Looking for places where I could find borland's advice, I could not find any. 
However I did find a lot of advices where they just suggest freeandnil(form1). 
 
to complete your explaination, do you have any url to where this suggestion 
could be found on the borland site?
 
It's not that I do not aggree, but I myself also used freeandnil(form1) untill 
now.
 
thanks
 
andries

Katja Bergman <[EMAIL PROTECTED]> wrote:
--- In [email protected], "rcloutie2004" <[EMAIL PROTECTED]>
wrote:
> The problem with Release, is that it doesn't set the form to nil.  
> The solution I found is to call Close method followed by FreeAndNil.
> 
> Hope this helps...

That's actually quite bad, do you realise that?
With forms, the Release method should be used instead of the Free
method. Basically, what you could do is this:

  Form1.Release;
  Form1 := nil;

In case you want your form to be nil afterwards.

Why use release? Simple. A form is receiving messages from the systems
and it might be busy processong one or more of those messages. Even
after you use 'Close', the form will just call 'Release' when it is
about to free itself. (Besides, 'Close' doesn't always free your form.
This behaviour depends on the CloseAction.)
So what if you free a form instead of releasing it? Well, it means
that some messages that should be handled by the form will not be
handled. Event handlers that are still active will also suddenly
terminate. If not, the result can be some nasty memory problems and
access violations afterwards.

The code that I've put above will work just fine. The Release command
will make sure the form gets freed eventually. By assigning Nil to the
Form variable, you can see if the form is unavailable now.

However, NEVER EVER FREE (or FreeAndNil) a form!

(Well, okay, you can call 'Free' outside any event handler of the
form, but it is just risky.)

rcloutie2004, so far you've just been lucky that your solution worked.
Borland advises against it. Listen to them, they know what they are
doing. :D

With kind regards,
X Katja Bergman.




-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 



SPONSORED LINKS 
C programming language Computer programming languages The c programming 
language C programming language List of programming languages Delphi programmer 

---------------------------------
YAHOO! GROUPS LINKS 


    Visit your group "delphi-en" on the web.
  
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


---------------------------------



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to