Hola.
Con Delphi 7 y superior podrías hacer algo como:
Código Delphi
[-]
...
implementation
uses TypInfo;
procedure TForm1.CambiarPropiedad(const AName, AProperty, AValue: string);
var
PInfo: PPropInfo;
TC: TComponent;
begin
TC:= FindComponent(AName);
PInfo:= GetPropInfo(TC.ClassInfo, AProperty);
if PInfo <> nil then
begin
case PInfo^.Proptype^.Kind of
tkString, tkLString: SetStrProp(TC, PInfo, AValue);
tkInteger: if (PInfo^.PropType^.Name = 'TColor') then
SetOrdProp(TC, PInfo, StringToColor(AValue))
else if (PInfo^.PropType^.Name = 'TCursor') then
SetOrdProp(TC, PInfo, StringToCursor(AValue))
else
SetOrdProp(TC, PInfo, StrToInt(AValue));
tkEnumeration: try
if (PInfo^.PropType^ = TypeInfo(System.Boolean)) then
SetOrdProp(TC, PInfo, StrToInt(AValue))
else
SetOrdProp(TC, PInfo, StrToInt(AValue));
except
raise;
end;
end;
end;
end;
Ejemplo de uso:
Código Delphi
[-]
CambiarPropiedad('edPuerto', 'Text', 'Hola');
CambiarPropiedad('edPuerto', 'Color', 'clLime');
CambiarPropiedad('edPuerto', 'Cursor', 'crHandPoint');
...
Saludos.