1

I am implementing a solution where I want my Delphi form to implement an interface. Normally, I would use TInterfacedObject but this a TForm. I implemented this without any regard to reference counting. And I did not see memory leaks reported.

TForm = class(TForm, ISomething)

But it seems if I don't inherit from TInterfacedObject, I should be implementing the three methods required.

Am I missing something?

Mike Stephenson
  • 649
  • 6
  • 14
  • 2
    You're not forced to implement reference counting methods. Take your `ISomething` interface implementation just as adding the interface methods into the class (your class will have to declare them). – TLama Dec 08 '19 at 17:14
  • It depends on what model of lifetime management you want to use. So, can you tell us that? – David Heffernan Dec 08 '19 at 17:22
  • 2
    Those methods are already implemented in TComponent and therefore in TForm, too. So you don't need to implement them. But it seems that you are actually asking about having reference counted TForm class? – Dalija Prasnikar Dec 08 '19 at 18:21
  • 1
    Related, [Will an interface-implementing form free itself when there are no more references to it?](https://stackoverflow.com/q/20386734/576719) – LU RD Dec 08 '19 at 18:26

0 Answers0