Board index » cppbuilder » Form Close

Form Close


2007-02-01 06:22:24 AM
cppbuilder20
I put some code inside OnClose event in the main form.
The code Action = caFree works fine when the form was closed by
the user, but it doesn't finish when the form was closed using
Close(); inside the program.
In both cases the event is called, but in the second case it does
not end the program until the user close it clicking in the
upper right corner of the window.
Any idea?
 
 

Re:Form Close

"Andrés de la Cuadra" < XXXX@XXXXX.COM >wrote in message
Quote
I put some code inside OnClose event in the main form.
This is not a component writing issue. Your question should have been
directed to a more appropriate newsgroup.
Quote
The code Action = caFree works fine when the form was
closed by the user, but it doesn't finish when the form was
closed using Close(); inside the program.
Yes, it does. What you are not taking into account is that caFree is
NOT an immediate destruction of the form. It posts a CM_RELEASE
message to the main message queue. The form is freed when the message
is processed later on.
Quote
In both cases the event is called, but in the second case it
does not end the program
Yes, it will. the program ends when the MainForm is closed for any
reason.
In any case, if you want to ensure that the program ends, you should
be calling Application->Terminate() instead of Close().
Quote
until the user close it clicking in the upper right corner of the
window.
All that does is causes Close() to be called like any other call.
Gambit
 

Re:Form Close

Andrés de la Cuadra wrote:
Quote
I put some code inside OnClose event in the main form.
The code Action = caFree
For a mainform that is not necessary as it will be cleaned up
automatically.
Hans.
 

{smallsort}