TStyleManager
does what you need to accomplish this task. Use TStyleManager.StyleNames
to get a list of the styles, and TStyleManager.TrySetStyle
to change them at runtime.
To see how this works, start a new VCL Forms Application
. Add all of the VCL styles you want to the project, and drop a TComboBox
on a form. You'll need to add the implementation
uses
clause like I have below:
uses
Vcl.Themes;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
TStyleManager.TrySetStyle(ComboBox1.Items[ComboBox1.ItemIndex]);
end;
procedure TForm1.FormShow(Sender: TObject);
var
s: String;
begin
ComboBox1.Items.BeginUpdate;
try
ComboBox1.Items.Clear;
for s in TStyleManager.StyleNames do
ComboBox1.Items.Add(s);
ComboBox1.Sorted := True;
// Select the style that's currently in use in the combobox
ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(TStyleManager.ActiveStyle.Name);
finally
ComboBox1.Items.EndUpdate;
end;
end;