Zitat von
DeddyH:
Und mit -1 kommt der Fehler auch?
Ja, allerdings verstehe ich das nicht.
Ich habe 3 Forms.
TfrmMain
TfrmLogin
TfrmAddEntry
in der TfrmMain wird das ganze gemacht und die for geht bis zum Index 3 (???).
Delphi-Quellcode:
for j := 0 to screen.FormCount-1 do
for i := 0 to screen.Forms[j].ComponentCount-1 do screen.Forms[j].Components[i].Tag := ((j+1) * 10000) + i;
for i := 0 to screen.Forms[j].ComponentCount-1 do
if (screen.Forms[j].Components[i] is TButton) or
(screen.Forms[j].Components[i] is TToolButton) or
(screen.Forms[j].Components[i] is TLabel) or
(screen.Forms[j].Components[i] is TMenuItem) or
(screen.Forms[j].Components[i] is TCheckBox) or
(screen.Forms[j].Components[i] is TRadioButton) or
(screen.Forms[j].Components[i] is TTabSheet) or
(screen.Forms[j].Components[i] is TSpeedButton) then
begin
if screen.Forms[j].Components[i] is TButton then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TButton(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TToolButton then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TToolButton(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TLabel then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TLabel(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TMenuItem then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TMenuItem(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TCheckBox then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TCheckBox(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TRadioButton then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TRadioButton(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TTabSheet then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TTabSheet(screen.Forms[j].Components[i]).Caption);
if screen.Forms[j].Components[i] is TSpeedButton then
handleList.Add(IntToStr(screen.Forms[j].Components[i].Tag)+'='+TSpeedButton(screen.Forms[j].Components[i]).Caption);
end;
end;
Ach ja, wenn jemand einen -sauberen- (!) weg kennt, alle Captions von Componenten, die Captions haben dürfen in eine Liste zu speichern, immer her damit. Damit ärgere ich mich nämlich schon geraume Zeit herum. Der Code ist mittlerweile auch ziemlich Dirty, da ich ständig dran rumändere.