Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Can FMX and VCL apps share data modules?



Permlink Replies: 6 - Last Post: May 2, 2015 2:17 AM Last Post By: Michael Justin
Mike Margerum

Posts: 590
Registered: 12/1/99
Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 20, 2015 5:57 AM
I tried to load the data module I created in the FMX app in my VCL app
and go an error indicating they were not compatible.

This seems really odd to me and I figured maybe im missing something. I
had planned to share some data modules between my VCL and FMX apps.
Robert Love

Posts: 155
Registered: 5/3/07
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 21, 2015 8:56 AM   in response to: Mike Margerum in response to: Mike Margerum
Mike Margerum wrote:
I tried to load the data module I created in the FMX app in my VCL app
and go an error indicating they were not compatible.

This seems really odd to me and I figured maybe im missing something. I
had planned to share some data modules between my VCL and FMX apps.

An Empty TDataModule can be shared between FMX and VCL.

TDataModule is defined in System.Classes.pas which can be used in both environments.

If you have used components that are specific to VCL or FMX on that data module then you would be linking to a specific platform.

Best to check your USES for VCL or FMX references.
Mike Margerum

Posts: 590
Registered: 12/1/99
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 3:01 PM   in response to: Robert Love in response to: Robert Love
Best to check your USES for VCL or FMX references.
Thanks robert, I just created a set of two projects.

1. vcl
2. fm

added a data module to vcl. dropped an TFDMemTable on it and that's all.

tried to add it to the fmx project and got the error

unit "dm.pas" is incompatible with the fmx framework,

it does let me continue, but i cant understand why i'm getting the
error. i assume TFDMemtable works on both platforms.

I'm guessing its this line (I did not add)

{%CLASSGROUP 'Vcl.Controls.TControl'}

what if i remove this?

Mike Margerum

Posts: 590
Registered: 12/1/99
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 3:04 PM   in response to: Mike Margerum in response to: Mike Margerum
I'm guessing its this line (I did not add)

{%CLASSGROUP 'Vcl.Controls.TControl'}

what if i remove this?


IF i create the datamodule in FMX I See this in the pas file.

{%CLASSGROUP 'FMX.Controls.TControl'}

I was working under the assumption that data modules are multi platform.
i was planning on putting some shared code in them for FDDataSets
Mike Margerum

Posts: 590
Registered: 12/1/99
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 3:05 PM   in response to: Mike Margerum in response to: Mike Margerum

I was working under the assumption that data modules are multi platform.
i was planning on putting some shared code in them for FDDataSets

I meant to say data modules I assumed data modules could be shared
between VCL and FMX projects.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2015 3:11 PM   in response to: Mike Margerum in response to: Mike Margerum
Mike wrote:

I was working under the assumption that data modules are multi
platform.

Read the documentation:

ClassGroup pseudo-property of TDataModule
http://docwiki.embarcadero.com/RADStudio/XE8/en/ClassGroup_pseudo-property_of_TDataModule

If you want the DataModule to be used in both frameworks, you need to set
its ClassGroup property to System.Classes.TPersistent.

--
Remy Lebeau (TeamB)
Michael Justin

Posts: 62
Registered: 10/27/99
Re: Can FMX and VCL apps share data modules?
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 2, 2015 2:17 AM   in response to: Mike Margerum in response to: Mike Margerum
Am 20.04.2015 um 14:57 schrieb Mike Margerum:
I tried to load the data module I created in the FMX app in my VCL app
and go an error indicating they were not compatible.

This seems really odd to me and I figured maybe im missing something. I
had planned to share some data modules between my VCL and FMX apps.

The XE8 documentation says that TDataModule is framework-neutral:

"When you create a data module, the unit file initially contains a
directive that sets the ClassGroup pseudo-property to a
framework-neutral base value" ... "System.Classes.TPersistent"

and

"Because TDataModule is initally framework-neutral, you can use a data
module with either the VCL or the FireMonkey framework."

http://docwiki.embarcadero.com/RADStudio/XE8/en/ClassGroup_pseudo-property_of_TDataModule

Maybe this has changed in XE8.

--
Michael Justin
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02