Delphi – TInterfacedDataModule revisted – use ‘inherited’ in your .dfm files when your datamodules look like forms in the designer
Posted by jpluimers on 2009/08/20
I got a few comments about people implementing the TInterfacedDateModule from my post Delphi – Using FastMM4 part 2: TDataModule descendants exposing interfaces, or the introduction of a TInterfacedDataModule.
After applying the ideas, and reloading the datamodules in Delphi , some of you got datamodules that looked like forms in the designer.
I should have been clearer: the solution for frames looking like forms in the designer from my post Delphi – Frames as visual Components – changing your inheritance also applies to datamodules. I hinted on that by writing This is caused by the fact that the IDE [...] does not recognize as a designable class like TFrame or TDataModule, but only covered the TFrame case.
So time to cover the or TDataModule case as well. :-)
If your datamodule suddenly looks like the image on the right, and/or you get complaints about properties like ClientHeight, ClientWidth, OldCreateOrder, PixelsPerInch or TextHeight, then need to change your dfm file.
A dfm file for a datamodule that indirectly descends from TDataModule should not have the object keyword as the first like this listing:
object MyDataModule: TMyDataModule
Left = 0
Top = 0
ClientHeight = 213
ClientWidth = 183
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
object DataSource1: TDataSource
Left = 64
Top = 38
end
end
In stead, such a dfm file should start with the inherited keyword as the first like this listing:

inherited MyDataModule: TMyDataModule
OldCreateOrder = True
Width = 190
object DataSource1: TDataSource
Left = 64
Top = 38
end
end
If you do so, then it will look like the picture on the right side again.
Hope that solves a few issues for a couple of you :-)
–jeroen










