AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Auflisten von Sub-Eigenschaften einer Komponente

Ein Thema von josef-b · begonnen am 31. Aug 2017 · letzter Beitrag vom 31. Aug 2017
Antwort Antwort
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.071 Beiträge
 
Delphi 10.4 Sydney
 
#1

AW: Auflisten von Sub-Eigenschaften einer Komponente

  Alt 31. Aug 2017, 12:11
Delphi-Quellcode:
procedure ListComponentProperties(ATypeInfo: PTypeInfo; Strings: TStrings); overload;
var
  Count, I: Integer;
  List: PPropList;
  PropInfo: PPropInfo;
  PropOrEvent: string;
begin
  List := nil;
  Count := GetPropList(ATypeInfo, List);
  try
    for I := 0 to Count - 1 do
    begin
      PropInfo := List^[I];
      case PropInfo.PropType^.Kind of
        TTypeKind.tkMethod:
          PropOrEvent := 'Event';
        TTypeKind.tkClass:
          begin
            ListComponentProperties(PropInfo.PropType^, Strings)
          end;
      else
        PropOrEvent := 'Property';
      end;
// PropValue := VarToStr(GetPropValue(Component, PropInfo^.Name)); <--- hier noch Gehirnschmalz reinstecken, da ja die Instanz fehlt

      Strings.Add('- - -' + Format('[%s] %s: %s = %s', [PropOrEvent, PropInfo^.Name, PropInfo^.PropType^.Name, '']));
    end;
  finally
    FreeMem(List);
  end;
end;

procedure ListComponentProperties(Component: TObject; Strings: TStrings); overload;
var
  Count, Size, I: Integer;
  List: PPropList;
  PropInfo: PPropInfo;
  PropOrEvent, PropValue: string;
begin
  List := nil;
  Count := GetPropList(Component, List);
  try
    for I := 0 to Count - 1 do
    begin
      PropInfo := List^[I];
      case PropInfo.PropType^.Kind of
        TTypeKind.tkMethod:
          PropOrEvent := 'Event';
        TTypeKind.tkClass:
          begin
            ListComponentProperties(PropInfo.PropType^, Strings)
          end;
      else
        PropOrEvent := 'Property';
      end;

      PropValue := VarToStr(GetPropValue(Component, PropInfo^.Name));

      Strings.Add(Format('[%s] %s: %s = %s', [PropOrEvent, PropInfo^.Name, PropInfo^.PropType^.Name, PropValue]));
    end;
  finally
    FreeMem(List);
  end;
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:18 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 by Thomas Breitkreuz