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

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

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

    Join 1,340 other followers

Delphi – TInterfacedDataModule revisted – use ‘inherited’ in your .dfm files when your datamodules look like forms in the designer

Posted by Jeroen Pluimers 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’ve not seen this behaviour in the IDE myself, but it must be a bug somewhere.

I should have been clearer when writing about the solution for frames looking like forms in the designer from my post Delphi – Frames as visual Components – changing your inheritance: that solution 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

4 Responses to “Delphi – TInterfacedDataModule revisted – use ‘inherited’ in your .dfm files when your datamodules look like forms in the designer”

  1. […] Heute, 19:56 Vielleicht object statt inherited im dfm? Schau mal was Jeroen dazu schreibt. Ibi fas ubi proxima merces sudo /Developer/Library/uninstall-devtools […]

  2. Angel4585 said

    As posted here: http://www.delphipraxis.net/177739-vererbung-zwischen-tdatamodules-wird-staendig-geloest.html#post1238304
    It seems to be a bug in the IDE. When I click the compiler-button or CTRL+F9 the inheritance between two DataModules is released.
    If you don’t change the size of the child only Height and Width is added to the sourcecode.
    But if you change the size ClientWidth and ClientHeight is added.

    If you change from object to inherited in Text-Mode manually you also need to switch to Designer-Mode to get and ignore all the Error-Messages.
    If you don’t switch back, you get these messages on Runtime.

  3. Anonymous said

    […] […]

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 )

Google+ photo

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

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 1,340 other followers

%d bloggers like this: