The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    MPS_5159

    MPS_5158

    MPS_5157

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,024 other followers

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 1,024 other followers

%d bloggers like this: