Home > other >  How to make an old form inherit from another?
How to make an old form inherit from another?

Time:01-22

I have an existing form and i want this form now, to inherit from another form.

For a new form i know how to do this, just go on File > New > Other > Inheritable items and select the father form. But what about an already existent form ?

Here is what i tried, change this :

type
  TFrmMyForm = class(TForm)

To this :

type
  TFrmMyForm = class(TFrmFatherForm)

But it doesn't seem to work, as FrmMyForm isn't importing FrmFatherForm components.

Is there a way to achieve this ?

Thanks

CodePudding user response:

Open dfm file in some other text editor and replace object with inherited

object FrmMyForm : TFrmMyForm

to

inherited FrmMyForm : TFrmMyForm

However, Delphi has issues with opening such forms if they don't belong to the same project. For instance, if you have base form declared in a package and you are using it to inherit forms in application or another package.

If you have problem opening such forms, make sure that you first open base form and then inherited.

  •  Tags:  
  • Related