Einzelnen Beitrag anzeigen

miLeRiAm

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

Re: Anzahl Formulare / Dynamisch Klassen ansprechen?

  Alt 31. Okt 2008, 11:54
Delphi-Quellcode:
 if handleList.Count = 0 then
 begin

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

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

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

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

    if (CompHasCaption(Comp, s)) then handleList.Add(IntToStr(comp.Tag)+'='+s);

   end; // for i = components

 end; // if list is empty

Wie wenig code das nur noch ist

VIELEN lieben Dank, hat mich viele Nerven gekostet.


Für alle die noch was setzen wollen, so gehts:

Delphi-Quellcode:
function CompSetCaption(AClass : TObject; Caption: string): Boolean;
const sProp = 'Caption';
var
  MyPropInfo: PPropInfo;
begin
  MyPropInfo := GetPropInfo(AClass.ClassInfo, sProp);
  Result := Assigned(MyPropInfo);
  if Result then
  begin
   SetPropValue(AClass, sProp, Caption);
   result := true;
  end else
   result := false;
end;
  Mit Zitat antworten Zitat