Как присвоить все значения полей одного класса, другому такому же классу 2
procedure EqualClassProperties(AClass1, AClass2: TObject); var PropList: PPropList; ClassTypeInfo: PTypeInfo; ClassTypeData: PTypeData; i: integer; NumProps: Integer; APersistent: TPersistent; begin if AClass1.ClassInfo <> AClass2.ClassInfo then exit; ClassTypeInfo := AClass1.ClassInfo; ClassTypeData := GetTypeData(ClassTypeInfo); if ClassTypeData.PropCount <> 0 then begin GetMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount); try GetPropInfos(AClass1.ClassInfo, PropList); for i := 0 to ClassTypeData.PropCount - 1 do if not (PropList[i]^.PropType^.Kind = tkMethod) then {if Class1,2 is TControl/TWinControl on same form, its names must be unique} if PropList[i]^.Name <> 'Name' then if (PropList[i]^.PropType^.Kind = tkClass) then begin APersistent := TPersistent(GetObjectProp(AClass1, PropList[i]^.Name, TPersistent)); if APersistent <> nil then APersistent.Assign(TPersistent(GetObjectProp(AClass2, PropList[i]^.Name, TPersistent))) end else SetPropValue(AClass1, PropList[i]^.Name, GetPropValue(AClass2, PropList[i]^.Name)); finally FreeMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount); end; end; end; Note that this code skips object properties inherited other than TPersistent.