Delphi XE2: Possible to instantiate a FireMonkey Form in VCL application?

This is perfectly possible, since the FMX form can be assigned to a panel.

This is perfectly possible, since the FMX form can be assigned to a panel. See this blog article for details: Just create a new FireMonkey form (2D or 3D, doesn't matter) save it and then add it to your VCL application (just accept the warning). You can create your FMX form instance somewhere and just show it - no problem.

But what if you want to create some nice control with animations or something and embed it into your existing VCL form? Well, put a TPanel on your VCL form and include the brandnew unit DSharp.Windows.FMXAdapter. Pas after the Vcl.ExtCtrls.

Then just create your FMX form somewhere and assign it to the new Form property of your Panel - and boom, there you go. In fact, the FMXAdapter. Pas code is very short: procedure TPanel.

Resize; begin inherited; ResizeForm(); end; procedure TPanel. ResizeForm; begin if Assigned(FForm) then Platform. SetWindowRect(FForm, RectF(BorderWidth, BorderWidth, ClientWidth + BorderWidth, ClientHeight + BorderWidth)); end; procedure TPanel.

SetForm(const AForm: TCommonCustomForm); begin FForm := AForm; FForm. BorderIcons := ; FForm. BorderStyle := TFmxFormBorderStyle.

BsNone; ResizeForm(); FForm. Visible := True; Winapi.Windows. SetParent(FmxHandleToHWND(FForm.

Handle), Handle); end.

1 Yes we can, that's what I like to hear. – Johan Sep 6 at 14:41 As stated by this blog review of XE2 article, even the IDE seems to embed some FireMonkey components inside its VCL forms: " Spy++ says the whole thing is only one window, of class FMTStyleDesigner. " So it's definitively a YES.

– Arnaud Bouchez Sep 7 at 6:26 @Arnaud: the link doesn't appear to work - was it meant to go to itinerantdeveloper.blogspot. Com/2011/09/c-builder-xe2. Html?

– David M Sep 15 at 11:13.

I haven't tried myself but I know of one confirmed way to mix VCL and FireMonkey in the same application using RemObjects Hydra and one unconfirmed report that you can have FireMonkey forms in a VCL application at Delphi Sorcery.

It is no big deal actually, to use both kinds of forms. But be sure that you instantiate them without any owner, as the owner types are not compatible. I just created two simple test projects, Project46 and Project47.

Project46 contained Unit25 with a VCL Form. Project 47 contained Unit26 with an FMX form. On Form25, I added a button, with the OnClick handler: procedure TForm25.

Button1Click(Sender: TObject); var F: Unit26. TForm26; begin F := TForm26. Create(nil); try F.

ShowModal; finally F. Free; end; end; This worked as expected. But the forms should otherwise be strictly indepedent of each other.

Only types they have in common can be exchanged.

All problems of the FMX+VCL mix can be resolved on the WinAPI level. But personally I don't recommend you to use such mix in the real world application.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions