Autor Beitrag
Daniel L.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: Do 07.10.10 12:05 
Hallo

ich versuche, alle childs einer Komponente, und auch deren childs usw. aufzuzeigen.

Beispiel: auf einer Form liegt Panel1.
Auf Panel1 liegen Panel2 und Button1.
Auf Panel2 liegt Button2.
Nun sollen alle child-Elemente von Panel1 und deren childs gezeigt werden.

Ich probiere das rukursiv mit controls, erhalte aber eine Fehlerlmeldung:


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure  TForm1.GetControls (Contrl : TWinControl);
var i : integer;
    co : TWinControl;
begin
for i := 0 to  contrl.ControlCount  - 1 do
   begin
     co := contrl.Controls  [i]; --> Fehler:"Inkompatible Typen: 'TWinControl' und 'TControl'"
     showmessage (contrl.Name);
     GetControls (co);
   end;
end;


Danke für Hilfe: Daniel Lutz


Zuletzt bearbeitet von Daniel L. am Do 07.10.10 12:35, insgesamt 1-mal bearbeitet
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 07.10.10 12:18 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure  TForm1.GetControls (Contrl : TWinControl);
var i : integer;
    co : TWinControl;
begin
for i := 0 to  contrl.ControlCount  - 1 do
   begin
     if  contrl.Controls[i] is TWinControl then
        begin
         co := TWinControl(contrl.Controls[i]);
         showmessage (co.Name);
         GetControls (co);
        end;
   end;
end;


aber Du suchst wahrscheinlich
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure  TForm1.GetParent (Contrl: TWinControl);
begin
  if Assigned(Contrl.Parent) then
    begin
    Showmessage(Contrl.Parent.Name);
    GetParent(Contrl.Parent);
    end;

end;


Zuletzt bearbeitet von bummi am Do 07.10.10 12:44, insgesamt 1-mal bearbeitet
Daniel L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: Do 07.10.10 12:38 
sorry, ich suche nach den Child-Komponenten und nicht nach den Parents.
Hab ich oben editert.

Daniel