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
| Function AffecteValeur(Composant:String;Valeur:String):Boolean;
Var NomFiche:String;
NomCompo:String;
NomProp :String;
Fiche :TForm;
Compo :TControl;
i,j :Integer;
begin
Result:=False;
// Recherche du nom de la fiche
i:=Pos('.',Composant);
NomFiche:=UpperCase(Trim(Copy(Composant,1,i-1)));
// Recherche du om du composant
j:=PosEx('.',Composant,i+1);
NomCompo:=Trim(Copy(Composant,i+1,j-i-1));
// Recherche du nom de la propriété
NomProp :=Trim(Copy(Composant,j+1,Length(Composant)-j));
// Tests
If (i=0)Or(j=0)Or(NomFiche='')Or(NomCompo='')Or(NomProp='') then Exit;
// Recherche de la fiche
Fiche:=Nil;
For i:=0 To Screen.FormCount-1 Do
If UpperCase(Screen.Forms[i].Name)=NomFiche Then
Begin
Fiche:=Screen.Forms[i];
Break;
End;
If Fiche=Nil Then Exit;
// Recherche du composant
Compo:=TControl(Fiche.FindComponent(NomCompo));
If Compo=Nil Then Exit;
// Mise à jour de la proriété
If IsPublishedProp(Compo,NomProp) Then
Begin
SetStrProp(Compo,NomProp,Valeur);
Result:=True;
End;
end; |
Partager