Edit And Store Custom Styles Within A TFrame In Delphi XE5 & XE6 Firemonkey On Android And IOS

Delphi XE5 XE6 Firemonkey Custom Style FramesA developer over on the Embarcadero forum has a tip about using a TFrame object to hold your custom styles in Delphi XE5 & XE6 Firemonkey. The basic idea is that you load up your custom styles into your TFrame and then you create your frame before any of the forms are created in the project file. By doing this you register those custom files with Delphi and that allows you to use them by name just like any other style from a StyleBook. I don’t quite understand the part about creating a custom style but Marco Cantu has a blog post for XE4 where he covers a custom style editor utility and some code to load styles with TStyleManager. There is also the MonkeyStyler utility for creating and editing your own styles. The key part to the forum post is where it explains how to reference the style names from the controls that you want to style. Here is an excerpt from the post:

Head over and read the full forum post about creating custom styles using a TFrame.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

4 Responses to Edit And Store Custom Styles Within A TFrame In Delphi XE5 & XE6 Firemonkey On Android And IOS

  1. Ilia Khubuluri says:

    sample code please ?

  2. Pau says:

    Hi Ilia.
    If you find a solution, please, paste it here.
    I have the same issues.

  3. Pau says:

    I have found the solution. There was not any problem.
    Here you are a sample:
    This is a style file for a button with font and backgrouncolor changed.
    You can add this style to your main style book with the add button in the style editor.


    object TStyleContainer
    object TLayout
    StyleName = ‘FlatBtn’
    Height = 22.000000000000000000
    Position.X = 457.000000000000000000
    Position.Y = 278.000000000000000000
    Width = 145.000000000000000000
    TabOrder = 0
    object TRectangle
    StyleName = ‘background’
    Align = Contents
    Fill.Color = claCoral
    Locked = True
    Height = 22.000000000000000000
    HitTest = False
    Stroke.Color = xFFC1C1C1
    Width = 145.000000000000000000
    object TInnerGlowEffect
    Softness = 0.400000005960464500
    GlowColor = xFF4F4848
    Opacity = 0.899999976158142100
    Trigger = ‘IsPressed=true’
    Enabled = False
    object TText
    StyleName = ‘text’
    Align = Client
    Locked = True
    Height = 18.000000000000000000
    HitTest = False
    Margins.Left = 5.000000000000000000
    Margins.Top = 2.000000000000000000
    Margins.Right = 5.000000000000000000
    Margins.Bottom = 2.000000000000000000
    Text = ‘Texto’
    TextSettings.Font.Style = [fsBold]
    TextSettings.FontColor = claWhite
    TextSettings.WordWrap = False
    Width = 135.000000000000000000

    Create a new firemonkey proyect.
    add a stylebook. Edit with dlb click and add the stylefile.
    Add a panel to the main form, and rename it to mypnl. This panel will be the parent of the frame.
    Add a frame to your proyect. File -> New -> other ->delphi file -> Firemonkey Frame
    Rename it to mycustombuttonframe
    Add a Tcornedbutton and set his stylelookup property to “flatbtn”
    you will not see the new style at designt time, but no problem.
    Set the property stylebook of the main form to stylebook1

    add a frame in the form class
    myframe : TFrame;

    Oncreate event of your form:

    myframe := Tframe(Tmycustombuttonframe.create(application));
    Myframe.parent := mypanel;

    Thats all.

  4. Pingback: What’s New Roundup For Delphi XE7 Firemonkey On Android, Windows, OSX, And IOS | Delphi XE5 XE6 XE7 Firemonkey, Delphi Android, Delphi IOS

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Use Frames To Simplify LiveBindings In Delphi XE5 & XE6 Firemonkey On Android And IOS

Cary Jensen has a blog post up where he outlines a tip to organize your Android and IOS apps by...