Salut,
c'est tout simple

Ajouer "TypInfo" au Uses
type
Tfrm_Main = class(TForm)
...
private
{ Déclarations privées }
procedure SetPropertys(ClassName: String;
SomeProperty: array of string; Value: array of Variant);
implementation
procedure Tfrm_Main.SetPropertys(ClassName: String; SomeProperty: array of string; Value: array of Variant);
var
i, j: integer;
PropInfo: PPropInfo;
Component: TComponent;
begin
for i := 0 to ComponentCount - 1 do
begin
Component := Components[i];
if (Component is TControl) and ((Component.ClassName = ClassName)
or (ClassName = 'AllComponents')) then
Begin
if High(SomeProperty) = High(Value) Then
for j := 0 to High(SomeProperty) do
Begin
PropInfo := GetPropInfo(Component.ClassInfo, SomeProperty[j]);
if Assigned(PropInfo) then
SetPropValue(Component, PropInfo.Name, Value[j]);
End
else
for j := 0 to High(SomeProperty) do
Begin
PropInfo := GetPropInfo(Component.ClassInfo, SomeProperty[j]);
if Assigned(PropInfo) then
SetPropValue(Component, PropInfo.Name, Value[0]);
end;
end;
end;
end;
Utilisation
SetPropertys('AllComponents',['Text'],['']);
si tu mets "Caption" à la place de "Text" la portée sera plus grande
ou
SetPropertys('TEdit',['Text'],['']);
ou
SetPropertys('TComboBox',['Text'],['']);
on peut aussi l'étendre à plusieurs propriétés:
SetPropertys('AllComponents', ['Enabled', 'Checked', 'Text'],[ True, False, '']);
SetPropertys('AllComponents', ['Enabled', 'Checked'],[ True]);
pour le reste ben faut tester soit même

@+
Cirec