Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the Style Name of a vsf file (VCL Style file)?

I have an application written in delphi-xe2, now i'm adding VCL styles support, So i want to build a menu to choose the vcl style file to load and apply, this part is working fine , the menu is build in runtime based in the content of a folder which has the style files. But now I want to display the name of the vcl style instead of filename just like this image

enter image description here

How I can get the name of the style of an vcl style file?

like image 922
Salvador Avatar asked Dec 23 '11 17:12

Salvador


1 Answers

You can use the TStyleManager.IsValidStyle function, passing a TStyleInfo record which return this and another info related to the vcl style.

Check this sample app

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  Vcl.Styles,
  Vcl.Themes;

var
 Style : TStyleInfo;
begin
  try
    if TStyleManager.IsValidStyle('C:\Users\Public\Documents\RAD Studio\9.0\Styles\RubyGraphite.vsf', Style) then
    begin
       Writeln(Format('Name           %s',[Style.Name]));
       Writeln(Format('Author         %s',[Style.Author]));
       Writeln(Format('Author EMail   %s',[Style.AuthorEMail]));
       Writeln(Format('Author URL     %s',[Style.AuthorURL]));
       Writeln(Format('Version        %s',[Style.Version]));
    end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  readln;
end.
like image 103
RRUZ Avatar answered Nov 15 '22 05:11

RRUZ