“Error creating form in Unit…fmx: FMX datamodules not supported.” when inherit from TDataModule descendant class

I have a problem (with sample project).

I have a TDataModule derived class to which I have added some properties and methods.

I wanted to make sure that it was possible to create a new instance of this class with a wizard similar to the one for TDataModules and also that it was possible to see the properties I added in the object inspector.

So I created the wizard and everything works fine.
The problem arises when, in an FMX project (if the project is VCL everything is fine), I add a new instance of this new class (with the wizard) then I try to inherit a further new derived class from this (visual form inheritance), I get the following error: “Error creating form in Unit3.fmx: FMX datamodules not supported.”

After much testing and research (and disturbing many friends) I came to the conclusion that the IDE does not recognize that you are inheriting from a TDataModule (indirectly) and behaves as if you were inheriting a new form, in fact it tries to create a file *.fmx instead of a *.dfm as is usually the case for DataModules even if the project is FireMonkey.

I have already verified that the pseudo property “ClassGroup” which determines the “affinity” of the DataModule to the VCL or FMX has nothing to do with this problem and neither does my code within my class derived from TDataModule so I believe that the the only two possibilities are:

  1. My wizard is not suitable for the creation of a TDataModule (derivative) in FMX projects, but the creation of the instance with the wizard itself works perfectly and in VCL projects there are no problems even inheriting

  2. Delphi’s IDE somewhere has to discriminate whether you are creating a Form or a DataModule and this “mechanism” has some problems with classes derived from TDataModule, as if the recognition that it is a DataModule was “hard- coded.”

So I ask anyone who can help me if you know a solution or work-around that is not manually editing the generated files (I already do that).

I created a minimal project from which I eliminated everything superfluous but complete with wizard, it allows you to verify the problem and maybe study it a little.

You can download it here: github.com/mauriziodm/MyDataModule.git

Proceed like this:

  1. Open the “MyDataModuleDT.dproj” project, do the build and then click on “Install” to install the generated package (wizard) in the IDE.
  2. Add the path where the source files are located in Delphi’s “Tools”.
  3. Create a new FMX project and save it somewhere
  4. Add a new TMyDataModule to the project (File > New > Other > MyDM > MyDataMule) and save
  5. Inherit from the MyDataModule added in step 4 (File > New > Other > Inheritable Items > MyDataModule2 (or the name you chose)), the error appears.

New contributor

Maurizio Del Magno is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

I inform you that, thanks to the contribution of Claudio Piffer, the problem has been solved.

Claudio tried to modify the ‘GetAncestorName’ method so that it returns the ‘DataModule’ value, in this way he informs the IDE of the fact that albeit indirectly (in my real case) the class is a DataModule and everything seems to work.

Even though in my real case the class does not derive directly from TDataModule it seems to work well without compromising anything else.

I had tried to do the same thing but modifying the value of a constant only that this, as well as in the indicated method, was also used elsewhere and then generated problems elsewhere, instead returning that value permanently without modifying anything else elsewhere everything is fine.

Now, in my real case the method is like this:enter image description here

New contributor

Maurizio Del Magno is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật