Delphi - generic datamodule

838 Views Asked by At

I am trying to define generics datamodule, something like this:

TDM<T> = class(TDataModule)
public
  function GetValue:T;virtual;abstract;
end;

But when I do this, Delphi misunderstood the datamodule and thinks its form (adds form properties like Client Width, Font, ... to .dfm file). I want this datamodule only for inheritance, so I tried to make it as simple class without .dfm file and then make real datamodule (with .dfm file) which inherits from it. Example:

TDataModule2 = class(TDM<Integer>)
public
  function GetType:Integer;override;
end;

Everything looks great, but only to moment, when I close and open project. On project opening, Delphi again interprets TDataModule2 as form for some reason (which causes exceptions on run).

I'm using Delphi XE. Is there any way to make this possible?

0

There are 0 best solutions below