Procedure CloneObject(O, O2: TObject;
Const Ignore:
Array of String);
Var List: PPropList;
i, i2: Integer;
Begin
i2 := GetPropList(O.ClassInfo, List);
If i2 > 0
Then
Try
For i := 0
to i2 - 1
do
If IsStoredProp(O, List[i].
Name)
and not MatchText(List[i].
Name, Ignore)
Then
Case List[i].PropType^.Kind
of
tkInteger, tkEnumeration, tkChar, tkWChar:
SetOrdProp (O2, List[i].
Name, GetOrdProp (O, List[i].
Name));
tkInt64: SetInt64Prop (O2, List[i].
Name, GetInt64Prop (O, List[i].
Name));
tkSet: SetSetProp (O2, List[i].
Name, GetSetProp (O, List[i].
Name));
tkFloat: SetFloatProp (O2, List[i].
Name, GetFloatProp (O, List[i].
Name));
tkLString: SetAnsiStrProp (O2, List[i].
Name, GetAnsiStrProp (O, List[i].
Name));
tkWString: SetWideStrProp (O2, List[i].
Name, GetWideStrProp (O, List[i].
Name));
{$IF Declared(UnicodeString)}
tkString, tkUString:
SetUnicodeStrProp(O2, List[i].
Name, GetUnicodeStrProp(O, List[i].
Name));
{$ELSE}
tkString: SetAnsiStrProp (O2, List[i].
Name, GetAnsiStrProp (O, List[i].
Name));
{$IFEND}
tkClass:
If MatchText(List[i].
Name, ['
CustomHint', '
Action', '
DropDownMenu', '
Images', '
PopupMenu'])
Then
SetObjectProp (O2, List[i].
Name, GetObjectProp (O, List[i].
Name))
Else If (GetObjectProp(O, List[i].
Name)
is TPersistent)
and ( GetObjectProp(O2, List[i].
Name)
is TPersistent)
Then
TPersistent(GetObjectProp(O2, List[i].
Name)).Assign(GetObjectProp(O, List[i].
Name)
as TPersistent);
tkMethod: SetMethodProp (O2, List[i].
Name, GetMethodProp (O, List[i].
Name));
tkVariant: SetVariantProp (O2, List[i].
Name, GetVariantProp (O, List[i].
Name));
Else Raise Exception.Create('
Propertytyp wird nicht unterstützt');
End;
Finally
FreeMem(List);
End;
End;