Autor Beitrag
shrubman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Sa 20.11.04 20:26 
Wie kann ich abfragen ob ein Label existiert ? ( was sich selbst erzeugt )
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Sa 20.11.04 20:34 
Wenn du den Namen weißt, dann mit FindComponent.

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: So 21.11.04 09:48 
theoretisch weiß ich das
denn ich sage im formular :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
for x:=1 to laenge do
begin
n:=n+10;
ausgabe[x]:=Tlabel.Create(Form1);
ausgabe[x].Parent:=Form1;
ausgabe[x].Caption:='_';
ausgabe[x].Height:=13;
ausgabe[x].Left:=20+n;
ausgabe[x].Top:=210;
ausgabe[x].Visible:=True;
ausgabe[x].Color:=$8F510A;
ausgabe[x].Font.Color:=$FFFFFF;
end;


dann müsste es ja ausgabe sein ( ausgabe global als array[1..20] of Tlabel definiert)
dann schreib ich das so aber es klappt nicht :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
for z:=1 to laenge do
begin
if
FindComponent(ausgabe[z])=true
then
begin
ausgabe[z].Destroy;
end;
end;

Inkompatible typen sagt er bei FindComponent
Hat jemand eine Idee???
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 21.11.04 11:02 
F1 hat folgendes geschrieben:
Die Methode FindComponent gibt an, ob der Komponente eine bestimmte Komponente untergeordnet ist.

function FindComponent(const AName: string): TComponent;

Beschreibung

FindComponent gibt diejenige Komponente im Array Components zurück, deren Name mit dem String im Parameter AName übereinstimmt. Mit Hilfe von FindComponent können Sie feststellen, ob eine bestimmte Komponente einer anderen Komponente untergeordnet ist.


also wäre eine Möglichkeit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
for x:=1 to laenge do
  begin
    n:=n+10;
    ausgabe[x]:=Tlabel.Create(Form1);
    ausgabe[x].Name:= 'autolabel' + IntToStr(x); // <<<
    ausgabe[x].Parent:=Form1;
    ausgabe[x].Caption:='_';
    ausgabe[x].Height:=13;
    ausgabe[x].Left:=20+n;
    ausgabe[x].Top:=210;
    ausgabe[x].Visible:=True;
    ausgabe[x].Color:=$8F510A;
    ausgabe[x].Font.Color:=$FFFFFF;
  end;


dann kannst du über

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
for z:=1 to laenge do
  begin
    if FindComponent('autolabel' + IntToStr(z))=true then
      begin
        ausgabe[z].Destroy;
      end;
  end;


alles ungetestet, dürfte aber gehen :roll:

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: So 21.11.04 11:52 
er sagt immer noch unkompatible typen bei der then zeile dürfte aber an der findcomponent zeile liegen
www.dorfjugend-eller...ichtig/Unbenannt.JPG

Moderiert von user profile iconChristian S.: Img- durch Url-Tags ersetzt
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 21.11.04 12:23 
entferne bitte dieses Bild aus deinem Post, ich muß mir das nicht runterladen!

findcomponent gibt ein TComponent zurück, nicht true oder false. Wird die koomponente nicht gefunden, wird nil zurückgegeben.

MFg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: So 21.11.04 13:15 
hmmm wenn ich true weglasse geht auch nicht... was muss ich denn schreiben ??
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 21.11.04 15:59 
shrubman hat folgendes geschrieben:
hmmm wenn ich true weglasse geht auch nicht... was muss ich denn schreiben ??


Keldorn hat folgendes geschrieben:
Wird die koomponente nicht gefunden, wird nil zurückgegeben.


Also wenn die Komponente gefunden wird, dann != nil.

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)