FMX.Styles.TStyleManager.SetStyleFromFile
Delphi
class function SetStyleFromFile(const FileName: string): Boolean; overload;
class function SetStyleFromFile(const Context: TFmxObject; const FileName: string): Boolean; overload;
C++
__classmethod bool __fastcall SetStyleFromFile(const System::UnicodeString FileName)/* overload */;
__classmethod bool __fastcall SetStyleFromFile(Fmx::Types::TFmxObject* const Context, const System::UnicodeString FileName)/* overload */;
Contents
Properties
| Type | Visibility | Source | Unit | Parent |
|---|---|---|---|---|
| function | public | FMX.Styles.pas FMX.Styles.hpp |
FMX.Styles | TStyleManager |
Description
Sets the style specified by FileName as the active style.
Do not place multiple lines calling SetStyleFromFile in a project, because you can have only one active style in the style manager.
You can call SetStyleFromFile either in the project source code (before calling Application.Initialize) or in the initialization section of one of the form units:
- If you call SetStyleFromFile in a form, the style is reapplied.
- If you call SetStyleFromFile before the form is created, the custom style fully replaces the platform style.
Example
This Delphi code demonstrates how to use the StyleManager:
Delphi:
procedure TForm1.FormCreate(Sender: TObject);
var
od : TOpenDialog;
begin
od := nil;
try
od := TOpenDialog.Create(self);
od.Filter := 'Style Files|*.style';
if od.Execute() then
TStyleManager.SetStyleFromFile(od.FileName);
finally
od.Free();
end;
end;