Fórum Sub-propriedades com RTTI #366886
08/12/2008
0
Tem como Varrer um componente qualquer e pegar as subpropriedades dele.
No exemplo a propriedade seria do tipo ´tkclass´, se fosse ele entraria na função
No exemplo BuscarValor(botao.Constraints) ele fuciona,
mas preciso que seja mais ou menos assim:
Count := GetPropList(botao.ClassInfo, tkany, nil);
for 0 to Count - 1 do
if propriedadeRequerida entao
BuscarValor(propriedadeRequerida);
em vez de //BuscarValor(botao.Constraints);
procedure BuscarValor(Dest:TPersistent);
var
wPropList:TpropList;
vCont,i:integer;
waux,waux2:string;
begin
vcont := getpropList(Dest.ClassInfo,tkany,@wPropList);
for i := 0 to vcont - 1 do
begin
if wPropList[i]^.proptype^.kind in [tkInteger] then
begin
wAux := getpropvalue(Dest,wPropList[I]^.name,false);
waux2 := wPropList[I]^.name + ´ Valor ´ + waux;
ListBox3.Items.Add(waux2);
end;
end;
No exemplo a propriedade seria do tipo ´tkclass´, se fosse ele entraria na função
No exemplo BuscarValor(botao.Constraints) ele fuciona,
mas preciso que seja mais ou menos assim:
Count := GetPropList(botao.ClassInfo, tkany, nil);
for 0 to Count - 1 do
if propriedadeRequerida entao
BuscarValor(propriedadeRequerida);
em vez de //BuscarValor(botao.Constraints);
procedure BuscarValor(Dest:TPersistent);
var
wPropList:TpropList;
vCont,i:integer;
waux,waux2:string;
begin
vcont := getpropList(Dest.ClassInfo,tkany,@wPropList);
for i := 0 to vcont - 1 do
begin
if wPropList[i]^.proptype^.kind in [tkInteger] then
begin
wAux := getpropvalue(Dest,wPropList[I]^.name,false);
waux2 := wPropList[I]^.name + ´ Valor ´ + waux;
ListBox3.Items.Add(waux2);
end;
end;
Acacio
Curtir tópico
+ 0
Responder
Posts
09/12/2008
Acacio
Descobri como fazer. Seria mais ou menos assim: Com alguns ajustes isso vai funcionar para o que eu preciso.
procedure BuscarValor(Dest: TObject);
Var
vPropList : TPropList;
vPropCount : Integer;
i : Integer;
waux,waux2:string;
begin
vPropCount := GetPropList(Dest.ClassInfo,tkAny,@vPropList);
for i := 0 to vPropCount-1 do
Begin
If vPropList[i]^.PropType^.Kind in [tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet, tkWChar, tkLString, tkWString, tkArray, tkInt64] Then
Begin
waux:= GetPropValue(Dest,vPropList[i]^.Name,false);
ListBox1.items.add(waux);
End;
end;
end;
var
wconta,i:integer;
vPropListaux :TPropList;
waux :string;
wobjecto:tObject;
begin
wconta := GetPropList(Button10.ClassInfo,tkAny,@vPropListaux);
for i := 0 to wconta-1 do
Begin
waux := vPropListaux[i]^.Name;
if waux = ´Constraints´ then
begin
wobjecto := GetObjectProp(Button10,waux);
AssignTo(wobjecto);
end;
end;
procedure BuscarValor(Dest: TObject);
Var
vPropList : TPropList;
vPropCount : Integer;
i : Integer;
waux,waux2:string;
begin
vPropCount := GetPropList(Dest.ClassInfo,tkAny,@vPropList);
for i := 0 to vPropCount-1 do
Begin
If vPropList[i]^.PropType^.Kind in [tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet, tkWChar, tkLString, tkWString, tkArray, tkInt64] Then
Begin
waux:= GetPropValue(Dest,vPropList[i]^.Name,false);
ListBox1.items.add(waux);
End;
end;
end;
var
wconta,i:integer;
vPropListaux :TPropList;
waux :string;
wobjecto:tObject;
begin
wconta := GetPropList(Button10.ClassInfo,tkAny,@vPropListaux);
for i := 0 to wconta-1 do
Begin
waux := vPropListaux[i]^.Name;
if waux = ´Constraints´ then
begin
wobjecto := GetObjectProp(Button10,waux);
AssignTo(wobjecto);
end;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)