How do I use a button duplicated in my style in FireMonkey? - delphi

I've created a style with the Bitmap Style Designer for Delphi XE7.
I've updated the button style to white with a blue border and duplicated it to create an orange button called Button_Copy.
I've exported the style to FireMonkey, but I can't find Button_Copy to assign it to a button on my form. How do I do this?
Also, can I rename Button_Copy to e.g. OrangeButton?

In the Bitmap Style Designer, save the style as a FireMonkey style.
Add a TStyleBook to your form.
Set the StyleBook property to the stylebook.
Double-Click the StyleBook and open your style. Close and Apply.
You can now set the StyleLookup property of a button to Button_Copy and if all is well you will see your new style.
Note that your new style won't appear in the selection list for StyleLookup - the list of available values appears to be hard coded.
And, of course you can change the name - just change the StyleName property of the top level object (probably a TLayout). The normalnaming convention is to append the word 'style', e.g. OrangeButtonStyle.

Related

How to use FMX Style Manager to create a fade out effect for TMemo

I am trying to add a fade-out effect to a TMemo control.
In the Form Designer it works quite well with a TLayout, TRectangle, and TMaskToAlphaEffect, as show in the screenshot on the left side. However, I would like to use the Style Designer (TStyleBook), as this seems the predestined approach and offers even more possibilities.
I have recreated it in the Style Designer, and in the Form Designer it looks as expected.
At runtime, however, the fade-out effect is not visible for TMemo styled by the TStyleBook. The "manually" styled TMemo is working fine.
As the Windows resources for the TStyleBook generates a ~83kb .fmx file, I had to upload the MCVE, which can be found on DropBox.
To do it on your own, follow these steps:
Open new FMX project
Add a TMemo to the form
Right click the TMemo and select "Edit Custom Stlyes..."
Select "background" under Memo1Style1 in the structure panel
Add a TRectangle from the component palette by double clicking
Select the Rectange1Style and change
Align to "Client"
Fill -> Kind to "Gradient"
Add a TMaskToAlphaEffect as child from the component palette by double clicking (Rectange1Style still selected)
Close the Style Designer and confirm applying the changes
If I change the Z-order of the TRectangle in the Style Designer, the effect also disappears in the Form Designer.
Am I missing something, or is it due to an incorrect Z-order at runtime, or is my approach fundamentally wrong?

Transparent Form in firemonkey with a stylebook

I have a application with multiple stylebooks containing styles from delphistyles.com. I want to add a trackbar to allow the user to change the transparency of the form at runtime like you can do in VCL with alphablend.
This post: AlphaBlend in FireMonkey says the following:
To make your form background semitransparent you should set form Transparency property to true and use Fill.Color with alpha value like $AAFFFFFF(with Fill.Kind = bkSolid). in this case form border becomes invisible (at least in Delphi XE2)
But how can I achieve this when my form has a stylebook?
Set TForm.Transparency to True
Put TPanel on the form with Align = Content
Use your TPanel as conteiner for all controls
Use TPanel.Opacity for transparency
Another thing is when the main form is transparent how can I go about making a titlebar for the user to drag the form?
I use my own class TWindowMove for moving forms without titlebar. Thats a small demo project

FMX progressbar color

Please be kind, I did my best with google, and found some guidance (also on StackOverflow), but none of it works for me.
FMX form with FMX Progressbar;
I only want to change the progressbar color from ugly yellow to cool skyBlue.
So far I've dropped a stylebook on the form;
I've added "progresscellstyle.htrack.hindicator" to the stylesheet designer;
It's the only one that even provides me with a color option (vs everything in "progressbarstyle treeitem") and that color does not influence my progressbar colour.
Please, a next step to decoding this problem if you could be so kind
Drop a TProgressBar on the form. Right click it and select Edit Custom Style. It should give you the style designer with a ProgressBar1Style1 object which contains htrack and vtrack.
htrack contains hindicator. Drop a TRectangle on the hindicator. Set the TRectangle to align Client. Change the Fill color as desired. Change the Stroke Kind to None.
vtrack contains vindicator. Drop a TRectangle on the vindicator. Set the TRectangle to align Client. Change the Fill color as desired. Change the Stroke Kind to None.
Close the style designer and save when it asks. This is one way to do it.
This may be a title old question, but the content about this is so rare that I think will be useful to future generations to have some info here.
To simply put, to change the color that will fill your bar you have to select a area in your BitmapLinks. To do that double click in the SourceLink property in the hindicator (a child of htrack in the tree view).
Then select a are that you will want to use as the filling, if none of the option pleases you, you may add a new BitMap to your StyleBook.
For the background color, just insert a rectangle inside htrack with a Client Alignment

Tabstop and TRectangle

I'm have TTabControl with some controls (Delphi XE7 Firemonkey app).
All works fine, tabstop too. Now I need to colorize one panel with CheckBox.
Add TRectangle to this panel and set parent for CheckBox to this TRectangle.
Interface looks fine but now this CheckBox not in the taborder list and not received tabstop command.
How to fix this issue?
How to reproduce: Add to the form TRectangle, add 3 CheckBox, move one CheckBox3 to the TRectangle using Structure panel (set TRectangle as parent for the CheckBox3). Run this application and try navigation using Tab key. You can't navigate to the CheckBox3!
You either have to manually set TabOrder to some (reasonable) value because TShape doesn't have it published and is thus set to -1 (which does the same thing as TabStop = False) or doesn't place the TCheckBox in the TRectangle, just place it in front of the TRectangle so it draws over the TRectangle.
Another option is not to use the TRectangle at all and change the style of the TPanel: Right click on the panel in the designer and select Edit Custom Style.... Then select the style newly created for you (something like panel1style: TRectangle) and change Fill property however you need. Click Apply and Close and you're done. By using styles you can create complex looks for any control that may look simple at first. For more information see http://docwiki.embarcadero.com/RADStudio/XE7/en/Customizing_FireMonkey_Applications_with_Styles and related topics.

How to change caption font color on TCheckBox, TRadioButton, TGroupBox?

I don't know what my problem is, but I cannot set the font color in DEx2 for controls like TCheckBox, TRadioButton, TGroubBox, and TRadioGroup. It doesn't matter if I do it in the IDE or programmatically.
I have set my form color to clBlack and want my captions to be clWhite, but they won't render any color but clBlack. When I assign a color on a form's OnShow event and step through it in the debugger, it shows the value I assigned it, but on the screen it is still black.
I am not using styles or anything else. Any ideas?
Here is a sample form:
white on black example http://www.skippix.us/temp/Delphi-Font-Problem.bmp
When you uses the windows themes in an application, most of the custom settings like the font colors are ignored. As workaround and depending of the component you can ownerdraw the control (only when this feature is supported), override the paint method in order to use your own color in the font (TRadioGroup, TGroupBox), and for components like TCheckBox and TRadioButton (which are WinAPI controls wrappers) you must intercept the WM_PAINT windows message and implement your own code to draw the control.
Also starting with Delphi-xe2 you can use the vcl styles which allow you to change the appearance of the controls, from here (and when is possible) you can modify the style hooks to apply your own font colors and other customizations.
A simple and easier workaround is to create a checkbox without caption and add a label after it. You can easily change the label's color. You can also create a new component that binds a label to the checkbox itself. That's what worked for me on Delphi 2007.
It will work under the following setting:
Project Options > Application > Runtime Themes = none

Resources