Author Topic: Inherits forms and release management  (Read 996 times)


  • Full Member
  • ***
  • Posts: 242
Inherits forms and release management
« on: April 17, 2024, 12:54:22 pm »

I have a conceptual problem that I would like to understand because I have problems relating to a program developed some time ago in the company where I work:
In the program I've a form A that inherits from TForm, a form B that inherits from form A and another form C that inherits from form B; clearly Form B adds functionality and so form C. Form c in addition to adding functionality, uses numerous Frames inside; in some of these frames there are Zeos tables hooked to ZupdateSql objects...
The onClose method is declared virtual and in my case class C has set TAction := cafree; my question is whether it is the right thing, i.e. should the automatic memory release method be implemented by Class A which derives from the TForm or by Class C which inherits from all the others?

Thanks in advance.

Thanks in advance.


  • Hero Member
  • *****
  • Posts: 2278
Re: Inherits forms and release management
« Reply #1 on: April 17, 2024, 03:37:45 pm »
TComponent and its descendants have built-in automatic memory release technology. This is the concept of the owner responsible for the destruction of the object.
Unless you specifically change this technology, it will work for any descendants.
When creating a form, a reference to the owner's object is passed to the constructor. For the main form, it is an application object that runs until it receives a termination signal. Usually the main form sends such a signal when closing.
By default, all forms except the main one are simply hidden when closed, not released. This technology is not related to the technology of automatic release by the owner of the components belonging to it.


TinyPortal © 2005-2018