Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.326 Beiträge
 
Delphi 12 Athens
 
#14

Re: Mehrere Steuerelemente mit der gleichen "Identität&

  Alt 16. Jul 2009, 15:44
Delphi-Quellcode:
Procedure Clone(C, C2: TObject);
  Var List: PPropList;
    i, i2: Integer;

  Begin
    i2 := GetPropList(C.ClassInfo, List);
    If i2 > 0 Then
      Try
        For i := 0 to i2 - 1 do
          If IsStoredProp(C, List[i].Name) and not MatchText(List[i].Name, ['Name', 'Parent']) Then
            Case List[i].PropType^.Kind of
              tkInteger, tkEnumeration, tkChar, tkWChar:
                         SetOrdProp (C2, List[i].Name, GetOrdProp (C, List[i].Name));
              tkInt64: SetInt64Prop (C2, List[i].Name, GetInt64Prop (C, List[i].Name));
              tkSet: SetSetProp (C2, List[i].Name, GetSetProp (C, List[i].Name));
              tkFloat: SetFloatProp (C2, List[i].Name, GetFloatProp (C, List[i].Name));
              tkLString: SetAnsiStrProp (C2, List[i].Name, GetAnsiStrProp (C, List[i].Name));
              tkWString: SetWideStrProp (C2, List[i].Name, GetWideStrProp (C, List[i].Name));
              {$IF Declared(UnicodeString)}
              tkString, tkUString:
                         GStUnicodeStrProp(C2, List[i].Name, GetUnicodeStrProp(C, List[i].Name));
              {$ELSE}
              tkString: SetAnsiStrProp (C2, List[i].Name, GetAnsiStrProp (C, List[i].Name));
              {$IFEND}
              tkClass: SetObjectProp (C2, List[i].Name, GetObjectProp (C, List[i].Name));
              tkMethod: SetMethodProp (C2, List[i].Name, GetMethodProp (C, List[i].Name));
              tkVariant: SetVariantProp (C2, List[i].Name, GetVariantProp (C, List[i].Name));
              Else Raise Exception.Create('Propertytyp wird nicht unterstützt');
            End;
      Finally
        FreeMem(List);
      End;
  End;
allerdings müßte tkClass noch etwas geändert werden, also speziell für Klassen, welche zum Objekt gehören und wo nur deren Inhalt kopiert werden müßte und nicht nur deren Referenz.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat