Hans
Hans

Reputation: 2262

Using FMX forms in a VCL application in XE7?

Even though it is not officially supported by Embarcadero there are many examples showing that you can include a FMX form in a VCL application e.g. MonkeyMixer and this SO question. However, when I create a test application with only one empty VCL form and one empty FMX form, I get two problems:

  1. There are two application icons in the task bar (apparently one for each instance of TApplication i.e. VCL and FMX)
  2. It crashes when I close the application (when it calls TStyleManager.UnInitialize in FMX.Forms.FinalizeForms).

How can I make this work?

I need this combination as we want our application to be native on Windows, Mac OS and iOS. Therefore on Windows it is a VCL application and the other OS's are FMX using the TMS native components. We have some large custom graphical components that are made for FMX, and they must also work on Windows.

Edit:

I see only two alternative solutions, and I like none of them:

  1. Use FMX on Windows too. I don't like the idea of styled components instead of native. Experienced users can easily tell the difference.
  2. Maintain to sets of our custom components: VCL and FMX editions. That will require some work, and also the graphical features of FMX are much better than VCL.

Upvotes: 2

Views: 1657

Answers (1)

Brian Frost
Brian Frost

Reputation: 13454

I've needed to host an FMX app inside a VCL app for display and training purposes. The FMX app is really an Android target and the VCL a Windows 'demonstrator'. The FMX hosting is done using TFireMonkeyContainer hosting the FMX main form. Yes it's got slight wrinkles but it works ok and I'm sure we'll find a way to improve things.

My FMX main form is created at runtime and has visibility of only FMX.Forms. It is then passed to TFireMonkeyContainer and is destroyed by it when the VCL app closes.

Upvotes: 2

Related Questions