Einzelnen Beitrag anzeigen

miLeRiAm

Registriert seit: 3. Sep 2004
Ort: :/root
34 Beiträge
 
RAD-Studio 2009 Pro
 
#13

Re: Anzahl Formulare in der Applikation

  Alt 31. Okt 2008, 11:24
Und so wird der Code immer schöner.
HasProperty ist zwar super, allerdings hilft mir das nicht weite.

Delphi-Quellcode:
 if handleList.Count = 0 then
 begin

  for j := 0 to screen.FormCount-1 do
  begin

   for i := 0 to screen.Forms[j].ComponentCount-1 do
   begin

    comp := screen.Forms[j].Components[i];

    comp.Tag := ((j+1) * 10000) + i;

      if comp is TButton then handleList.Add(IntToStr(comp.Tag)+'='+TButton(comp).Caption);
      if comp is TToolButton then handleList.Add(IntToStr(comp.Tag)+'='+TToolButton(comp).Caption);
      if comp is TLabel then handleList.Add(IntToStr(comp.Tag)+'='+TLabel(comp).Caption);
      if comp is TMenuItem then handleList.Add(IntToStr(comp.Tag)+'='+TMenuItem(comp).Caption);
      if comp is TCheckBox then handleList.Add(IntToStr(comp.Tag)+'='+TCheckBox(comp).Caption);
      if comp is TRadioButton then handleList.Add(IntToStr(comp.Tag)+'='+TRadioButton(comp).Caption);
      if comp is TTabSheet then handleList.Add(IntToStr(comp.Tag)+'='+TTabSheet(comp).Caption);
      if comp is TSpeedButton then handleList.Add(IntToStr(comp.Tag)+'='+TSpeedButton(comp).Caption);

   end; // for i = components

  end; // for j = forms

 end; // if list is empty

Das Problem bleibt bestehen, dass ich in Delphi (bisher) keine Möglichkeit gefunden habe, Klassen dynamisch zuzuweisen, z.B. so:

TClass('TLabel').Caption
oder
TClass(comp.ClassName).Caption

Das kann in Delphi nie klappen, da man sofort die Klassentypen benötigt um auf etwas zuzugreifen.
Es wird nicht einfach compiliert in der Hoffnung der User weiß genau was er da gerade zusammenbaut.

Ideen?
  Mit Zitat antworten Zitat