FMXTStyleManager (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example shows how to use the TStyleManager.SetStyleFromFile method in order to set the style of the form at run time.

To build and test this example create a new Multi-Device Application and add the following code to the OnCreate event handler of the form. Also include the FMX.Styles unit in the uses clause.

Note: You can also set the style of a form at design time, using a style book component.

Code

procedure TForm2.FormCreate(Sender: TObject);
var
  OpenDialog: TOpenDialog;
begin
  OpenDialog := nil;
  try
    OpenDialog := TOpenDialog.Create(self);
    OpenDialog.Filter := 'Style Files|*.style';//Use a filter to show only the style files.
    if OpenDialog.Execute() then //Show the dialog and if the user clicked OK,
      TStyleManager.SetStyleFromFile(OpenDialog.FileName);//load the selected style and set it as the active style.
  finally
    OpenDialog.Free();
  end;
end;

Uses

See Also