--- 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.




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12ho1tp4i/M=362335.6886445.7839731.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1124886519/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

-----------------------------------------------------
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