Bonjour, cette discussion est plus ou moins parallèle à celle-ci

mon objectif, à moyen terme :
Extraire les couleurs "systeme"
Extraire les png d'un style s'ils existent (totalement optionnel si l'on a les vsf) mais ...
Très long terme
Modifier un style FMX (sans passer par le concepteur de bitmap), la partie sauvegarde étant déjà réglé par ShaiLeTroll et son helper dans la discussion sus-citée.

j'en suis là
Nom : Capture.PNG
Affichages : 106
Taille : 28,7 Ko
dans la partie gauche (un Tmemo avec les informations obtenues en "vrac")
Dans la partie droite, un treeview avec les propriétés qui m'intéressent (ou du moins une partie des)

Je voudrais la valeur des propriétés couleur, pour obtenir les propriétés j'utilise ce code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
procedure TMain.oi(afmxobj: TFMXObject; aNode : TTreeViewItem=nil);
var crtti : TRttiContext;
    trtti : TRttiType;
    prtti : TRttiProperty;
    sprop  : String;
    sl : TstringList;
    color : TAlphaColor;
    aChildnode : TTreeViewItem;
begin
crtti:=TRttiContext.Create;
try
   sl:=TStringList.Create(TDuplicates.dupIgnore,true,true);
   try
   trtti:= crtti.GetType(afmxObj.ClassType);
   for prtti in trtti.GetProperties do
    begin
 
     sProp:=prtti.Name;
     If prtti.PropertyType.TypeKind In
                [tkInteger, tkChar
                 , tkFloat
                 , tkString
                 , tkWChar, tkLString, tkWString
                 , tkEnumeration
                 ]
     then begin
        if Prtti.Name.ToLower.Contains('color')
           then  Sl.Add(Sprop); // ici pb de transformation de prtti.GetValue(afmxobj) en couleur
 //       if sametext(Prtti.Name,'stylelookup') then
 //           sl.add(sprop+'='+prtti.GetValue(afmxobj).tostring);  // ici revoir présentation ?
     end;
 
    end;
    for var s in sl do begin
      memo1.lines.add(#9#9+s);
      if Anode<>nil then
        begin
          aChildNode:=TTreeViewItem.Create(aNode);
          aChildnode.Text:=S;
          aNode.AddObject(achildnode);
        end;
    end;
   finally
     sl.Free;
   end;
finally
  crtti.free;
end;
end;
J'ai tenté un truc genre color:=TalphaColor(prtti.GetValue(afmxobj).asVariant) mais j'ai une "Erreur de vérification d'étendue at address ..."
Ce sera donc ma question du jour.

[Edit] je pense que je ne suis pas aller explicitement sur le comment j'obtiens les données
Même s'il y a beaucoup de reproche à faire sur ce "truc" et qu'il faudra très certainement passer par un thread
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
procedure TMain.BtnAnalyseClick(Sender: TObject);
var
    ms : TMemoryStream;
    MyFunc: TFunc<TFmxObject, TEnumProcResult>;
    TVItem,ANode : TTreeViewItem;
    S : String;
begin
  
  // chargement fichier style déporté niveau menu

  MyFunc := function(AObject: TFmxObject): TEnumProcResult
    begin
      memo1.BeginUpdate;
      s:=AObject.StyleName;

      if not s.IsEmpty then
      begin
         if  (AObject.Parent=Stylebook1.Style) then
         begin
         TVItem:=TTreeViewItem.Create(TreeView1);
         TVItem.Text:=S;
         TreeView1.AddObject(TVItem);
         ANode:=TVItem;
         Oi(Aobject,TVItem);
        end
        else begin
           TVItem:=TTreeViewItem.Create(TreeView1);
           TVItem.Text:=S;
           Anode.AddObject(TVItem);
           if AObject is TStyledControl then
             S:=#9+ S +#9+TStyledControl(Aobject).StyleLookup
           else s:= #9 + S;
           Oi(Aobject,TVItem);
         end;
        memo1.lines.add(s);
      end;

      Oi(Aobject);
  
      Result := TEnumProcResult.Continue;
      memo1.EndUpdate;
    end;

  Memo1.Lines.Clear;
  StyleBook1.style.EnumObjects(MyFunc);

  // sauvegarde ShaiLeTroll 
  // MS:=TmemoryStream.Create;
  // Stylebook1.Styles.Items[0].SaveToStream(MS, FMX.Styles.TStyleFormat.text);
  // Ms.Position:=0;
  // Ms.SaveToFile('testtext.style');
  // ms.free;
end;