Einzelnen Beitrag anzeigen

SarDGer

Registriert seit: 19. Mai 2005
55 Beiträge
 
Delphi 7 Professional
 
#1

Vor SetPropValue auf ReadOnly testen

  Alt 27. Mai 2010, 12:19
Moin Moin,

ich hab da ein kleines Problem...
Ich will die Properties eines Objects in die
Properties eines anderen Objects kopieren.

Delphi-Quellcode:
function CopyPropValues(aSourceObj, aDestinationObject : TPersistent): Boolean;
var
  I : Integer;
  propCount : Integer;
  PropInfo : PPropInfo;
  PropList : PPropList;
begin
  propCount := GetPropList(aSourceObj, PropList);
  for I := 0 to propCount - 1 do
  begin
    PropInfo := PropList^[I];

    case PropInfo^.PropType^.Kind of
      tkClass : SetObjectProp(aDestinationObject, PropInfo.Name, GetObjectProp(aSourceObj, PropInfo.Name));
      tkMethod : SetMethodProp(aDestinationObject, PropInfo.Name, GetMethodProp(aSourceObj, PropInfo.Name));
      else
        SetPropValue(aDestinationObject, PropInfo.Name, GetPropValue(aSourceObj, PropInfo.Name));
    end;
  end;

  FreeMem(PropList);
end;
Soweit so lustig. Allerdings haut es sich weg wenn die Property ReadOnly ist.
Was ja nachvollziebar ist. Aber wie prüfe ich vor dem Set nach ob die aktuelle
Prop nu readOnly ist oder nicht.

Vielen dank im voraus.
Sar D'Ger
  Mit Zitat antworten Zitat