Einzelnen Beitrag anzeigen

Benutzerbild von mirage228
mirage228

Registriert seit: 23. Mär 2003
Ort: Münster
3.750 Beiträge
 
Delphi 2010 Professional
 
#8

Re: Caption, Text, Hint, etc. von Komponenten rausfinden

  Alt 31. Mai 2004, 14:59
Hi!

So gehts:

1) Ein neues Formular erstellen
2) Eine ComboBox druff
3) Eine ListBox druff
4) OnFormCreate definieren (Code siehe unten)
5) OnComboBoxChange definieren (Code siehe unten)
6) Voila

Delphi-Quellcode:
uses
  TypInfo

// .....
procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  ComboBox1.Clear;
  for i := 0 to Self.ComponentCount-1 do
    ComboBox1.Items.Add(Form1.Components[i].Name);
  ComboBox.Text := '';
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  PropList: PPropList;
  i: Integer;
  CompName: String;
begin
  PropList := AllocMem(SizeOf(PropList^));
  i := 0;
  CompName := ComboBox.Items[ComboBox1.ItemIndex];
  ListBox1.Items.Clear;
  try
    GetPropList(FindComponent(CompName).ClassInfo,
      [tkString, tkLString, tkWString], PropList);
    while (PropList^[i] <> nil) and
      (i < High(PropList^)) do
    begin
      ListBox1.Items.Add(PropList^[i].Name);
      inc(i);
    end;
  finally
    FreeMem(PropList);
  end;
end;
mfG
mirage228
David F.

May the source be with you, stranger.
PHP Inspection Unit (Delphi-Unit zum Analysieren von PHP Code)
  Mit Zitat antworten Zitat