Autor Beitrag
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Sa 03.03.07 17:31 
Hallo,
ich erstelle durch folgenden Code zur Laufzeit ein Label:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button3Click(Sender: TObject);
var
  NewLabel: TLabel;
begin
  NewLabel := TLabel.Create(Self);
  NewLabel.Name := 'Nav99';
  NewLabel.Left := 128;
  NewLabel.Top := 600;
  NewLabel.Height := 23;
  NewLabel.Width := 500;
  NewLabel.Font.Size := 12;
  NewLabel.Parent := Self;
  Newlabel.Caption := 'test';
  NewLabel.Visible := true;
end;


Jetzt möchte ich auf diese Komponente Zugreifen, z.B. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button4Click(Sender: TObject);
begin
  ShowMessage(Nav99.Caption);
end;


Das geht aber natürlich nicht, da das Label ja nicht deklariert ist. Wie kann ich also jetzt auf dieses Label zugreifen.

Später möchte ich auch noch ein OnClick ereignis auf dieses Label machen, da hab ich auch noch keine Ahnung wie ich das machen kann.

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 03.03.07 17:34 
Entweder über Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT oder aber Du deklarierst das Label in der Form-Klasse und nicht in der Prozedur. Vielleicht hilft auch dieser Beitrag weiter (steht auch was zu Events drin): www.delphi-library.d...verwalten_43052.html

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 03.03.07 17:35 
hier bauste das feinste speicherleck... du kannst so auf deinen pointer nicht mehr zugreifen, wenn du ihn nicht irgendwo hast...

daher, MERKEN!!!

z.b. in einen eigenen array...
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Sa 03.03.07 18:00 
user profile iconGrenzgaenger hat folgendes geschrieben:
hier bauste das feinste speicherleck... du kannst so auf deinen pointer nicht mehr zugreifen, wenn du ihn nicht irgendwo hast...

daher, MERKEN!!!

z.b. in einen eigenen array...


Hat er ja. Da das Form Owner und Parent vom Label ist, befindet das Label sich in den Listen Components und Controls des Forms.

Ein Speicherleck wird's eh nicht geben, da das Form (als Owner) das Label automatisch mit freigibt.
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mo 05.03.07 07:54 
Habe die Labels jetzt so erstellt, wie es auf dieser Seite erklärt ist:
www.delphi-library.d...verwalten_43052.html
Jetzt habe ich ein Problem, alles läuft wunderbar, bis dann wenn ich das Programm beende, da bekomme ich einen Fehler: EInvalidPointer

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 05.03.07 08:23 
kann es sein, dass Du das Label per Hand freigibst? Das mußt Du nicht, denn der Parent kümmert sich darum!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Mo 05.03.07 09:26 
user profile iconKroko hat folgendes geschrieben:
kann es sein, dass Du das Label per Hand freigibst? Das mußt Du nicht, denn der Parent kümmert sich darum!

Meinst du die automatische Freigabe der "Unterkomponenten" bei der eigenen Freigabe? Das macht nicht der Parent, das macht der Owner.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 05.03.07 09:35 
mag ja sein, aber erst wenn Parent gesetzt wird!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Mo 05.03.07 11:05 
user profile iconKroko hat folgendes geschrieben:
mag ja sein, aber erst wenn Parent gesetzt wird!

Nein.
Ein Owner gibt die Unterkomponente auch frei, wenn er nicht gleichzeitig Parent ist.
Eine Unterkomponente wird auf diese Weise auch freigegeben, wenn sie keinen Parent hat.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 05.03.07 11:44 
wieder dazu gelernt :lol:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mo 05.03.07 15:20 
Also ich habe jetzt folgendes versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  i: Integer;
begin
  for i:=1 to LinkAnzahl-1 do
  begin
    LabelArray[i].Destroy;
    //LabelArray[i].Free;
  end;
end;

Sprich ich hab es mit Free, Destroy und auch ohne die beiden versucht, bekomme aber immernoch den Pointer error.

Erstellen tue ich meine Komponenten ja so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
for i:=1 to LinkAnzahl do
  begin
    oben := oben + 25;
    tmpStr := ini.ReadString('LinkID' + IntToStr(i),'Name',tmpStr);
    LabelArray[i] := TLabel.Create(self);
    with LabelArray[i] do
    begin
      parent := self;
      left := 10;
      top := oben;
      name := 'Link'+IntToStr(i);
      Caption := tmpStr;
      onClick := editEvent;
      Font.style := [fsBold];
      if Screen.Width <= 1360 then
        font.size := 8
      else
        font.size := 12;
      font.color := clBlue;
    end;
  end;

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 05.03.07 15:26 
lass das Freigeben ganz weg, darum kümmert sich der Owner :!:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Mo 05.03.07 15:33 
Wenn die Labels das Form als Owner haben, dann vergiss deine TForm1.FormClose-Prozedur. Die Labels werden von Form1 automatisch freigegeben.

Wenn du die Prozedur weglässt und dann das Programm beendest, bekommst du dann noch einen Fehler? Und welchen genau?

Wo genau werden deine Labels erzeugt - also in welcher Prozedur genau?
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mo 05.03.07 16:15 
Ich bekomme folgende Fehlermeldung, wenn ich die Close-Prozedure weglasse:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt CockpitChart.exe ist eine Exception der Klasse EInvalidPointer aufgetreten. Meldung: 'Ungültige Zeigeroperation'. Prozeß wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
---------------------------
OK Hilfe
---------------------------


Die Labels erstelle ich bei Form1.create

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Mo 05.03.07 16:48 
user profile iconBronstein hat folgendes geschrieben:
Ich bekomme folgende Fehlermeldung, wenn ich die Close-Prozedure weglasse:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt CockpitChart.exe ist eine Exception der Klasse EInvalidPointer aufgetreten. Meldung: 'Ungültige Zeigeroperation'. Prozeß wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
---------------------------
OK Hilfe
---------------------------

Dann gehe mal davon aus, dass deine Labels da nichts mit zu tun haben.
Oder zumindest nicht die Teile, die du uns als Code hier gepostet hast.
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Fr 09.03.07 21:52 
Titel: Symbol was eliminated by linker
Jetzt hab ich doch noch ein Problem beim erstellen der Labels.

Der Name des Labels wird einfach nicht gesetzt. In der Anlage habe ich mal mein Projekt.
Einloggen, um Attachments anzusehen!
_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 09.03.07 22:07 
1.) Ich finde es schade, dass du ein Thema von dir nicht ordentlich zum Abschluss bringst.
Man versucht, dir zu helfen und will dann auch hören, ob die Hilfe etwas gebracht hat, bzw. wie du es ansonsten gelöst hast. (So geht mir das jedenfalls).

2.) Jetzt hängst du an ein altes Thema ein völlig neues ran. Damit hätten wir ein unfertiges Problem mit anschließender neuer Frage, die eigentlich nur so halb (wenn überhaupt) damit zu tun hat.

Okay:
Hier die Antwort. Du begehst die (in meinen Augen) Unart, with XXX do zu benutzen. Dabei benutzt du Übergabeparameter, die genau so heißen, wie Eigenschaften von XXX. Und schon läuft nix mehr.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.Label_erstellen(aname, text: String; tmpleft, tmptop, LabelIndex: Integer; Komponent : TComponent; WinKontrol: TWinControl);
begin
  LabelArray[LabelIndex] := TLabel.Create(Komponent);
  with LabelArray[LabelIndex] do
  begin
    parent := WinKontrol;
    left := tmpleft;
    top := tmptop;
    name := aname;
    Caption := text;
    onClick := editEvent;
    Font.style := [fsBold];
    if Screen.Width <= 1360 then
      font.size := 8
    else
      font.size := 12;
    font.color := clBlue;
  end;
end;

Ich habe den Übergabeparameter name in aname geändert. Jetzt kann der übergebene Parameter von der Eigenschaft TLabel.Name unterschieden und dieser zugewiesen werden. (Nicht vergessen: auch in Klasse TForm1 ändern!)

Damit ist deine Frage beantwortet.

Dein nächstes Problem ist jetzt, dass du in Objektnamen keine Punkte haben darfst. Du versuchst als Namen "List11.1" und sowas zu übergeben. Das ist nicht erlaubt und bringt jetzt den nächsten Fehler.

Für eine eventuelle neue Frage erstelle bitte einen neuen Thread.
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Fr 09.03.07 22:35 
Ich denke dieses Problem passt noch zu diesem Thema.

Wenn ich jetzt auf ein Label klicke möchte ich die bisher erstellten löschen und danach die das neue Menü aufbauen. Ich dachte mit dass ich das so mache:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.editEvent(sender : TObject);
var
  name: String;
  i: Integer;
begin
  name := TLabel(sender).Name;
  name := Zeichen_Ersetzen(name, '_', '.');

  for i:=0 to 29 do
  begin
    if LabelArray[i] <> nil then
    begin
      LabelArray[i].Free;
      LabelArray[i] := nil;
    end;
  end;

  MenueAktualisieren(self, self, name);
end;


Das funktioniert auch einmal, doch wenn ich dann wieder auf ein Label klicke bekomme ich den Fehler:
Access violation.

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 09.03.07 23:02 
Entschuldige bitte, aber die Procedure war bis eben noch (in deinem Upload) ohne jegliche Label-Freigabe.

Du entwickelst fleißig an deinem Programm und jede Frage zu deinen Labeln landen hier in diesem Thread. Damit verkommt er zu einer Art "Online-Entwicklungshilfe". Die kann und möchte ich aber in dieser Form nicht so einfach leisten. Daher klinke ich mich hier aus.

Benutze Haltepunkte und Einzelschritt und solche Dinge. Ich bin sicher, so manches Problem verdient es, etwas länger von dir analysiert zu werden, bevor sofort in Foren nachgefragt wird. Dabei lernst du auch am meisten.
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Sa 10.03.07 13:42 
Ich bekomme es einfach nicht hin. Hier mal der Code, vielleicht kann mir ja doch noch jemand weiterhelfen. Ansonsten werde ich es sein lassen:

Komisch ist, wenn ich das Programm mit Einzelschritten (F7) duchgehe, bekomme ich den Fehler nicht.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IniFiles, StdCtrls, ComCtrls, jpeg, ExtCtrls, DateUtils;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure editEvent(sender : TObject);
    procedure Label_erstellen(aname, text: String; tmpleft, tmptop, LabelIndex: Integer; Komponent : TComponent; WinKontrol: TWinControl);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  LabelArray: array of TLabel;


implementation

{$R *.dfm}

function Teilstring_Ersetzen(Text, Suchen, Ersetzen:String):String;
var Flags: TReplaceFlags;
begin
  Flags:=[];
  Flags:=[rfIgnoreCase];
  // ohne rfReplaceAll wird nur die erste Fundstelle ersetzt
  // durch rfIgnoreCase wird Groß- und Kleinschreibung ignoriert
  result:=StringReplace(Text, Suchen, Ersetzen, Flags);
  // 'Suchen' ist der zu ersetzende Teil, 'Ersetzen' der neu eingefügte Teil
end;

function Zeichen_Ersetzen(Text: String; altZeichen: char; neuZeichen: char):String;
begin
  while Pos(altZeichen, Text) > 0 do
    Text[Pos(altZeichen, Text)] := neuZeichen;
  result:= Text;
end;

procedure LinkFarbe(Index: Integer);
var
  i: Integer;
begin
  //Farben für den Link bestimmen, wenn man die For schleife weg lässt werden alle Unterpunkte grau
  for i:=0 to 29 do
  begin
    if LabelArray[i] <> nil then
    begin
      LabelArray[i].Font.Color := clBlue;
    end;
  end;
  LabelArray[Index].Font.Color := clGray;
end;

procedure Bild_Laden(Pfad: String);
var
  tmpFloat: Extended;
begin
  Pfad := Teilstring_Ersetzen(Pfad, 'Jahr', IntToSTr(YearOf(now)));
  Pfad := Teilstring_Ersetzen(Pfad, 'Monat', FormatDateTime('mmmmm', now));
  Form1.Image1.Picture.LoadFromFile(Pfad);

  //Bildgröße an Bildschirmgröße anpassen
  tmpFloat := Form1.Image1.Picture.Width / 100;
  tmpFloat := Form1.Image1.Width / tmpFloat;
  tmpFloat := (Form1.Image1.Picture.Height / 100) * tmpFloat;
  Form1.Image1.Height := Trunc(tmpFloat);
end;

procedure MenueAktualisieren(Komponent : TComponent; WinKontrol: TWinControl; aktLink: String);
var
  LinkAnzahl1, LinkAnzahl2, LinkAnzahl3, LinkAnzahl4, LinkAnzahl5, LinkAnzahl6, LinkAnzahl7: Integer;
  a, b, c, d, e, f: Integer;
  tmpLink1, tmpLink2, tmpLink3, tmpLink4, tmpLink5, tmpLink6, tmpLink7: String;
  LabelIndex, top: Integer;

  ini: TiniFile;
  Dauer, tmp: Integer;
  sl: TStringList;
  i, oben: Integer;
  tmpStr, tmpPfad, pfad: String;
begin
  LabelIndex := 0;
  top := 60;
  pfad := ExtractFilePath(ParamStr(0));
  pfad := pfad + 'CockpitChart.ini';
  ini:=TIniFile.Create(pfad);
  LinkAnzahl1 := ini.ReadInteger('RootItems','RootItemsCount', LinkAnzahl1);
  for a:=1 to LinkAnzahl1 do  //Menü Stufe 1
  begin
    tmpStr := ini.ReadString('RootItems', 'Item' + IntToStr(a), tmpStr);
    tmpLink1 := 'Link' + IntToStr(a);
    Form1.Label_erstellen(tmpLink1, tmpStr, 5, top, LabelIndex, Komponent, WinKontrol);
    inc(LabelIndex);
    top := top + 20;
    LinkAnzahl2 := ini.ReadInteger(tmpLink1,'ItemsCount', LinkAnzahl2);

    if copy(aktLink, 1, 5) = tmpLink1 then
    begin
      tmpPfad := ini.ReadString('RootItems', 'Image' + IntToStr(a), tmpPfad);
      Bild_Laden(tmpPfad);
      LinkFarbe(LabelIndex-1);
      for b:=1 to LinkAnzahl2 do  //Menü Stufe 2
      begin
        tmpStr := ini.ReadString(tmpLink1, 'Item' + IntToStr(b), tmpStr);
        tmpLink2 := 'Link' + IntToStr(a) + '.' + IntToStr(b);
        Form1.Label_erstellen(tmpLink2, tmpStr, 15, top, LabelIndex, Komponent, WinKontrol);
        inc(LabelIndex);
        top := top + 20;
        LinkAnzahl3 := ini.ReadInteger(tmpLink2,'ItemsCount', LinkAnzahl2);

        if copy(aktLink, 1, 7) = tmpLink2 then
        begin
          tmpPfad := ini.ReadString(tmpLink1, 'Image' + IntToStr(b), tmpPfad);
          Bild_Laden(tmpPfad);
          LinkFarbe(LabelIndex-1);
          for c:=1 to LinkAnzahl3 do  //Menü Stufe 3
          begin
            tmpStr := ini.ReadString(tmpLink2, 'Item' + IntToStr(c), tmpStr);
            tmpLink3 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c);
            Form1.Label_erstellen(tmpLink3, tmpStr, 25, top, LabelIndex, Komponent, WinKontrol);
            inc(LabelIndex);
            top := top + 20;
            LinkAnzahl4 := ini.ReadInteger(tmpLink3,'ItemsCount', LinkAnzahl4);

            if copy(aktLink, 1, 9) = tmpLink3 then
            begin
              tmpPfad := ini.ReadString(tmpLink2, 'Image' + IntToStr(c), tmpPfad);
              Bild_Laden(tmpPfad);
              LinkFarbe(LabelIndex-1);
              for d:=1 to LinkAnzahl4 do  //Menü Stufe 4
              begin
                tmpStr := ini.ReadString(tmpLink3, 'Item' + IntToStr(d), tmpStr);
                tmpLink4 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d);
                Form1.Label_erstellen(tmpLink4, tmpStr, 35, top, LabelIndex, Komponent, WinKontrol);
                inc(LabelIndex);
                top := top + 20;
                LinkAnzahl5 := ini.ReadInteger(tmpLink4,'ItemsCount', LinkAnzahl5);

                if copy(aktLink, 1, 11) = tmpLink4 then
                begin
                  tmpPfad := ini.ReadString(tmpLink3, 'Image' + IntToStr(d), tmpPfad);
                  Bild_Laden(tmpPfad);
                  LinkFarbe(LabelIndex-1);
                  for e:=1 to LinkAnzahl5 do  //Menü Stufe 5
                  begin
                    tmpStr := ini.ReadString(tmpLink4, 'Item' + IntToStr(e), tmpStr);
                    tmpLink5 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d) + '.' + IntToStr(e);
                    Form1.Label_erstellen(tmpLink5, tmpStr, 45, top, LabelIndex, Komponent, WinKontrol);
                    inc(LabelIndex);
                    top := top + 20;
                    LinkAnzahl6 := ini.ReadInteger(tmpLink5,'ItemsCount', LinkAnzahl6);

                    if copy(aktLink, 1, 13) = tmpLink5 then
                    begin
                      tmpPfad := ini.ReadString(tmpLink4, 'Image' + IntToStr(d), tmpPfad);
                      Bild_Laden(tmpPfad);
                      LinkFarbe(LabelIndex-1);
                      for f:=1 to LinkAnzahl6 do  //Menü Stufe 6
                      begin
                        tmpStr := ini.ReadString(tmpLink5, 'Item' + IntToStr(f), tmpStr);
                        tmpLink6 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d) + '.' + IntToStr(e) + '.' + IntToStr(f);
                        Form1.Label_erstellen(tmpLink6, tmpStr, 55, top, LabelIndex, Komponent, WinKontrol);
                        inc(LabelIndex);
                        top := top + 20;
                        LinkAnzahl7 := ini.ReadInteger(tmpLink6,'ItemsCount', LinkAnzahl7);

                        if copy(aktLink, 1, 15) = tmpLink6 then
                        begin
                          tmpPfad := ini.ReadString(tmpLink5, 'Image' + IntToStr(f), tmpPfad);
                          Bild_Laden(tmpPfad);
                          LinkFarbe(LabelIndex-1);
                        end;
                      end;
                    end;
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
    end;
  end;
end;

procedure TForm1.Label_erstellen(aname, text: String; tmpleft, tmptop, LabelIndex: Integer; Komponent : TComponent; WinKontrol: TWinControl);
var Test: TLabel;
begin
  aname := Zeichen_Ersetzen(aname, '.', '_');
  LabelArray[LabelIndex] := TLabel.Create(Komponent);

  with LabelArray[LabelIndex] do
  begin
    parent := WinKontrol;
    left := tmpleft;
    top := tmptop;
    name := aname;
    Caption := text;
    onClick := editEvent;
    //Font.style := [fsBold];
    if Screen.Width <= 1360 then
      font.size := 8
    else
      font.size := 12;
    font.color := clBlue;
  end;
end;

procedure TForm1.editEvent(sender : TObject);
var
  name: String;
  i: Integer;
begin
  name := TLabel(sender).Name;
  name := Zeichen_Ersetzen(name, '_', '.');

  for i:=0 to 29 do
  begin
    if LabelArray[i] <> nil then
    begin
      LabelArray[i].Free;
      LabelArray[i] := nil;
    end;
  end;

  MenueAktualisieren(self, self, name);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  Fensterbreite, tmp: Integer;
begin
  SetLength(LabelArray, 30);
  MenueAktualisieren(self, self, 'Link2.2');

   //Objekte an Größe anpassen
  if Screen.Width <= 1360 then
  begin

    Image1.Left := 150;
  end
  else
    Image1.Left := 240;

  Fensterbreite := Screen.Width;
  Label1.Left := (Fensterbreite div 2) - (Label1.Width div 2);

  Form1.Panel1.Left := 0;
  Form1.Panel1.Width := Fensterbreite;

  Image1.Width := (Fensterbreite - Image1.Left) - 10;

  tmp := Fensterbreite - Image1.left;
  tmp := tmp div 2;
  tmp := tmp + Image1.Left - (Button1.Width div 2);
  Button1.Left := tmp ;

  tmp := Fensterbreite - Image1.left;
  tmp := tmp div 2;
  tmp := tmp + Image1.Left - (Button2.Width div 2);
  Button2.Left := tmp ;
  //Hintergrundfarbe
  Form1.Color := RGB(15, 185, 185);
  Form1.Panel1.Color := RGB(15, 185, 185);

  Button1.Top := Image1.Top + Image1.Height + 50;
  Button2.Top := Image1.Top + Image1.Height + 80;
    //Fenster maximieren
  Form1.WindowState := wsMaximized;
end;

end.

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!