![]() |
Vor SetPropValue auf ReadOnly testen
Moin Moin,
ich hab da ein kleines Problem... Ich will die Properties eines Objects in die Properties eines anderen Objects kopieren.
Delphi-Quellcode:
Soweit so lustig. Allerdings haut es sich weg wenn die Property ReadOnly ist.
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; 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 |
Re: Vor SetPropValue auf ReadOnly testen
Hallo,
Ich bin mir nicht sicher, aber vllt hilft:
Delphi-Quellcode:
?
if Assigned(PropInfo^.SetProc) then
SetPropValue(...); Edit: Habs getestet und so geht es bei mir :wink: |
Re: Vor SetPropValue auf ReadOnly testen
Hab's auch getested und bei mir sieht's auch gut aus :-D
SetProc und GetProc beziehen sich offenscheinlich auf die Getter bzw Setter Routine. Oh mann, hätte ich auch selber drauf kommen können, aber manchmal ist man wie vernagelt. Vielen Dank für die schnelle Antwort, Sar D'Ger |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:16 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz