Connecting Tech Pros Worldwide Forums | Help | Site Map

Error Using FormDestroy method in Borland C++ 6.0

deepakmitbhu@yahoo.co.in
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi,

I'm developing a database application using Borland C++ 6.0.
In one of the form the application throws an error when exiting
because of the following peace of code.when code inside the function
is removed it works perfectly.
void __fastcall Tf_ftp::FormDestroy(TObject *Sender)
{
AddToLog(Memo1->Lines);
}

The FormDestroy method is called when MainForm tries to destroy a
module in the application.
The troublesome code works perfectly elsewhere.

Please throw some light on FormDestroy function and it's handling.

Regards,

Deepak

Thomas Matthews
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Error Using FormDestroy method in Borland C++ 6.0


deepakmitbhu@yahoo.co.in wrote:
[color=blue]
> Hi,
>
> I'm developing a database application using Borland C++ 6.0.
> In one of the form the application throws an error when exiting
> because of the following peace of code.when code inside the function
> is removed it works perfectly.
> void __fastcall Tf_ftp::FormDestroy(TObject *Sender)
> {
> AddToLog(Memo1->Lines);
> }
>
> The FormDestroy method is called when MainForm tries to destroy a
> module in the application.
> The troublesome code works perfectly elsewhere.
>
> Please throw some light on FormDestroy function and it's handling.
>
> Regards,
>
> Deepak[/color]

You will have to ask in a Borland newsgroup, as this newsgroup
is only concerned with _standard_ C++ which has no knowledge
of the FormDestroy function.

How scary, the operating system can destroy modules in an
application!

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Bob Hairgrove
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Error Using FormDestroy method in Borland C++ 6.0


On 23 Jun 2004 06:16:31 -0700, deepakmitbhu@yahoo.co.in wrote:
[color=blue]
>Hi,
>
>I'm developing a database application using Borland C++ 6.0.
>In one of the form the application throws an error when exiting
>because of the following peace of code.when code inside the function
>is removed it works perfectly.
>void __fastcall Tf_ftp::FormDestroy(TObject *Sender)
>{
> AddToLog(Memo1->Lines);
>}
>
>The FormDestroy method is called when MainForm tries to destroy a
>module in the application.
>The troublesome code works perfectly elsewhere.
>
>Please throw some light on FormDestroy function and it's handling.
>
>Regards,
>
>Deepak[/color]

This is a VCL-related problem of order of construction/destruction.
The quick answer is: do not use FormDestroy for anything that needs
access to any members of your class, especially other VCL objects.
They have already gone by the time FormDestroy() is called. Use
OnClose() or the destructor of your form's class.

VCL doesn't follow the rules of C++.

--
Bob Hairgrove
NoSpamPlease@Home.com
Closed Thread