0

I need a form for testing Styles. And go apllying each style only in that form. But the TStyleManager.SetStyle applies to all forms in application. How can I do for apply style only in current form?

    procedure TForm1.FormCreate(Sender: TObject);
    var styleName: String;
    begin
      ListBox1.Items.Clear;
      for styleName in TStyleManager.StyleNames do
        ListBox1.Items.Add(styleName);
    end;
.......
    procedure TForm1.ListBox1Click(Sender: TObject);
    begin // this applies to all forms in application, I want apply only this form!
      TStyleManager.SetStyle(ListBox1.Items[ListBox1.ItemIndex]);
    end;
LU RD
  • 34,438
  • 5
  • 88
  • 296
user3017774
  • 11
  • 1
  • 1

1 Answers1

4

The VCL Styles are application wide, and are not designed to only be applied to a particular form. But you can disable the styles in the forms and the controls removing the elements from the StyleElements property.

Now according to your question "I need a form for testing Styles..." maybe you are looking a preview form for the VCL Styles and if that is the case you can try this article Exploring Delphi XE2 – VCL Styles Part III which explains how create a preview for the VCL Styles. Also the VCL Styles Utils project includes a component called TVCLStylesPreview and sample application of how use it.

Check this sample image of the component

enter image description here

RRUZ
  • 134,889
  • 20
  • 356
  • 483