How do you style the non-client area in a Firemonkey FM2 application in Delphi XE3
Asked Answered
S

1

8

I previously asked this question in the Delphi XE2 timeframe, and the answer then was a pretty ugly hack.

Now Delphi XE3 supports non-client theming, according to the official release notes. How do you do it in Delphi XE3 in Firemonkey FM2?

I believe it must be something to do with the style-book, but I can't figure it out. The form itself has an "EnableBorderStyling" property which I set to true, and I am thinking I must have to load a style that contains some nonclient theme data, but I can't find a style that includes it.

The help has nothing about this subject.

Update2 Okay, it's not broken, it's just that I don't have a style that contains this style element (as RRUZ says).

procedure TForm1.FormShow(Sender: TObject);
begin
  StyleBook := StyleBook1;
  WindowBorder.UpdateStyle;
end;

Update3: Style files appear to be in two different locations, which is confusing:

  C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\Redist\styles\Fmx        
  C:\Users\Public\Documents\RAD Studio\10.0\Styles

Note that I don't have a Luna.Style (firemonkey style) in either spot, however 5 seconds with the Style Editor tool. (Open, and Save as, and change type to .Style, and I had one!)

Update4: RRUZ's answer works, but on my system (Windows 8 RTM) the non-client styles don't look right, they have white corners around the areas of the on't fully paint . Resizing the window makes it go away, and I'm pretety sure I should be able to force a WM_NCREPAINT or something, and make it go away.

Scene answered 4/10, 2012 at 3:5 Comment(9)
Yes, it comes from the style. I haven't fully investigated, but look in the FMX.Forms unit at the TWindowBorder object which is what pulls out the styles.Pretext
Okay. I'll read the FMX.Forms sources and see if I can figure out. There are no demos/samples included either.Scene
Relevant blog post from Embarcadero staff person on this subject: blogs.embarcadero.com/ekryukov/2012/10/03/…Scene
@WarrenP I did not understand how you make to get the Luna.Style, what file did you open? I dont have any luna.* on my windows 8 box. And I really need to add the non-client area in a thin border with icons and same color as form´s background in XE5. Appreciate any help.Forefinger
The Luna.Style doesn't come with it, but of course, a Luna.vsf DOES, which I just open in the Style Designer, then Save As and change type to .Style (Fmx) and I've got the .Style file, and it contains the needed type. – (Comment on answer below! Did you even READ everything?)Scene
@WarrenP Actually I am with piles of doubts with piles of articles reading and a crazy deadline for a new Firemonkey application... Sorry I supposedly read everything, but I did not got everything... One last question, can i delete everything and just this type on the style to be added to the current one I am using? piles of thank youForefinger
Dude, I have no idea what you're talking about.Scene
@WarrenP windowborderstyle is needed to change the non-client area, right? I am using a Style that does not come with it (MetropolisUIBlue) and I needed it.. I know nothing of style to create it from scratch. Is it possible to COPY this windowborderstyle from other Styles? and change the properties (mainly color i think)Forefinger
I have never tried it. Go ahead and try it. What stops you from trying?Scene
B
6

To Style the non client area of a Firemonkey application the selected style must have a windowborderstyle element defined (as is show in the picture)

enter image description here

From the styles included with delphi try the Luna.Style

enter image description here

Benenson answered 5/10, 2012 at 2:11 Comment(4)
The Luna.Style doesn't come with it, but of course, a Luna.vsf DOES, which I just open in the Style Designer, then Save As and change type to .Style (Fmx) and I've got the .Style file, and it contains the needed type.Scene
This works, but a little workaround (forcing a WM_NCREPAINT after the first time my window draws itself) seems to be needed to get the "transparency" to work properly at the window border corners. Thanks very much. Hopefully they'll (a) unify the Style location in ONE place, and (b) ship both .VSF and .Style files for all styles out of the box in XE3 Update 1.Scene
@Benenson I am using a Style that does not contain the windowborderstyle, How can I add that? I dont see in Design Editor how to do that? I need to change the non-client are of the MetropolisUI style. There are there the details of non-client are (different icons for buttons etc) but there is nothing that I could find to define this tag.Forefinger
@eelias, which version of Delphi are you using?Benenson

© 2022 - 2024 — McMap. All rights reserved.