0

我需要一个表格来测试样式。并且仅以这种形式应用每种样式。但是 TStyleManager.SetStyle 适用于应用程序中的所有表单。如何仅以当前形式应用样式?

    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;
4

1 回答 1

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

于 2013-11-21T14:32:41.790 回答