14
votes

Here is a sample of a delphi application I am making using firemonkey + Delphi XE2.

As you can see, you can use the visual style "stylebook" in Firemonkey to customize the appearance of most things inside the window frame. However the outside of the window frame is drawn using whatever style Windows decides. Now if I was using VCL instead of Firemonkey, I could apply "VCL Styles" and "skin" the whole VCL application in a dark color scheme.

My guess is that this is NOT YET posssible with Delphi XE2 + Firemonkey. Can anyone show how to do this?

enter image description here

At designtime, the "preview" of your form shows a nice black border. But when I run my app, the Windows XP "Luna" theme border (the blue parts in the picture below) looks atrocious. Ironically, the VCL is prettier (in XE2 with styles) than Firemonkey...

3
Yes. I didn't find any video, image or tutorial of a Firemonkey style applied in runtime on a windows frame. I suppose is not possible yet (or at least not without "ninja" skills)EMBarbosa
It also seems it is not possible to apply styles to TMainMenu yet.Warren P

3 Answers

4
votes

You can create a VCL Forms application as usual, with styles if you like, at runtime load your Firemonkey form and set your VCL form as its parent:

uses
  FMX.Platform.Win, FMX.Forms,
  Unit2;

procedure TForm1.FormCreate(Sender: TObject);
var
  Form2: TForm2;
begin
  Form2 := TForm2.Create(nil);
  Form2.BorderStyle := FMX.Forms.TFmxFormBorderStyle.bsNone;
  Form2.SetBounds(0, 0, ClientWidth, ClientHeight);
  Winapi.Windows.SetParent(FmxHandleToHWND(Form2.Handle), Handle);
  Form2.Show;
end;

In the following screenshot, Form1 is the VCL application main form (with Carbon style) and the dark-grey area with the button is the embedded Firemonkey form:

Firemonkey form embedded in a VCL form

Note that I'm not handling resizing of the parent window - it should resize the emebedded form, too, emulating alClient alignment. It seems there are many potential problems with this approach - I think there's a reason why the IDE doesn't let you easily mix Firemonkey forms with VCL forms - it warns about possible "compilation errors or unexpected behavior."

2
votes

Firemonkey is cross platform. By and large you cannot do anything that is platform dependent within the FMX framework itself. You can however make calls to the underlying platform (be it windows, OSX or iOS) to access platform specific functionality. This should be done within conditionally compiled code.

eg.

{$IF DCC}
  something;
{$ENDIF}

{$IF FPC}
  somethingelse;
{$ENDIF}

Looking at it from another viewpoint, it may be possible for you do do all of your FMX work on a TRectangle (for example), then use AddObject (or assign its parent), to a VCL form.

0
votes

If you change the forms BorderStyle to bsNone, you can add whatever chrome you want. You will, of course, need to manually handle maximise, minimise, close, resize etc actions.