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