A 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:
you can apply the styles you created in the frame by referencing their stylenames to the styledcontrols in other forms. In design time, make sure you just keep the style frame open, so that style could take effect in design time. Not opening the style frame in design time doesn't affect the effect in runtime though.
Head over and read the full forum post about creating custom styles using a TFrame.
sample code please ?
Hi Ilia.
If you find a solution, please, paste it here.
I have the same issues.
Greetings.
Pau.
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.
MyStyle.style
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
end
end
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
end
end
end
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.
Greetings,
Pau.