Autor Beitrag
DaKirsche
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 187

Win XP Pro, SuSe Linux 7.3 - 10.2, Win 2k3 Server, Win 2000, Win NT 4.0
Delphi 2006 Pro, Java, HTML, SQL, PHP, CSS
BeitragVerfasst: Mo 12.02.07 12:34 
Hallo Alle zusammen....

ich schreibe gerade ein Programm und in diesem Programm soll eine dynamische Anzahl an TLabels (und später TCheckboxen) erstellt werden.
Dazu habe ich folgende prozedur:
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:
procedure TForm7.RunInit();
var TempIni:TIniFile;
TeamCount,GroupCount,TeamsPerGroup,i,xcoord:Integer;
LabelTemp:TLabel;
begin
try //IniFile
TempIni:=TIniFile.Create(ExtractFilePath(Paramstr(0))+'\temp.ini');
with TempIni do begin
//Einlesen der Variablen
 TeamCount:=StrToInt(ReadString('Mannschaftskonfiguration','MaxNumberOfTeams','0'));
 TeamsPerGroup:=StrToInt(ReadString('Mannschaftskonfiguration','TeamsPerGroup','0'));
 GroupCount:=StrToInt(ReadString('Mannschaftskonfiguration','NumberOfPlayingTeams','0'));
//Teamzusammenstellung
xcoord:=100;
 For i:= 1 to TeamCount do begin
    try  //Label
    LabelTemp:=TLabel.Create((findcomponent('Panel1')as TPanel));
     with LabelTemp do begin
       parent:=(findcomponent('Panel1')as TPanel);
       LabelTemp.Name:='Mannschaft'+IntToStr(i);
       Left:=50;
       Top:=xcoord;
       font.color:=clblack;
       font.Name:='MS Sans Serif';
       enabled:=true;
       width:=150;
       height:=20;
       font.Size:=10;
       Caption:=ReadString('TeamDefinitions','Team'+IntToStr(i),'');
       visible:=true;
     end;//with LabelTemp
      LabelTemp.free;
      xcoord:=xcoord+25;
     except //Label
     showmessage('Label konnte nciht initialisiert werden!');
     end; //Try Label
 end; //For i
end;   //with TempIni
TempIni.Free;
except //IniFile
    showmessage('Fehler bei temporärer Sicherungsdatei. Datei nicht gefunden!');
end;     //Try IniFile
end;     //procedure RunInit


Soweit so gut...

Also:
Beim Compilieren wird mir kein Fehler angezeigt, beim Funktionsaufruf ebenfalls nicht.
Das Programm stürzt nicht ab und garnix...jedoch wird keine TLabel Komponente erstellt...zumindest nicht angezeigt.

Kann mir jeman sagen, wie ich dieses Problem beheben kann????

Vielen Dank schonmal.
Mfg
DaKirsche

_________________
Die simpelsten Fehler sind meist die Schwersten...
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 12.02.07 12:39 
Deine Labels haben kein parent.
ausblenden Delphi-Quelltext
1:
2:
3:
LabelTemp:=TLabel.Create((findcomponent('Panel1')as TPanel));
     with LabelTemp do begin
       parent:=(findcomponent('Panel1')as TPanel);

Du machst erst ein "with" und damit ein "findcomponent". Da suchst Du wohl an der falschen Stelle. Außerdem könnte immer noch Nil dabei raus kommen. Hättest Du eine entsprechende Prüfung drin, wäre Dir das vermutlich selbst aufgefallen.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 12.02.07 12:40 
Hi,

schonmal überprüft was in TeamCount steht, bzw ob du deine INI Datei richtig lädst (Dateiname richtig? Werte richtig? etc?)
und.. falls da alles stimmt, rufst du die RunInit-Procedure überhaupt auf? :P

Ansonsten sehe ich so spontan keinen Fehler.. (Zumindest keinen, der nicht wenn er da wäre eine Fehlermeldung bringen würde)

Meoow~
Aya~~

_________________
Aya
I aim for my endless dreams and I know they will come true!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 12.02.07 12:40 
1. Warum ersetzt du findcomponent('Panel1')as TPanel nicht durch Panel1?
2. Du gibst das Label ja noch in der selben Schleife wieder frei, dann kann es nicht angezeigt werden.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 12.02.07 12:41 
user profile iconGTA-Place hat folgendes geschrieben:
2. Du gibst das Label ja noch in der selben Schleife wieder frei, dann kann es nicht angezeigt werden.

Stimmt, das hab ich übersehen :oops:

_________________
Aya
I aim for my endless dreams and I know they will come true!
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 12.02.07 12:42 
Ich auch. Aber soweit habe ich den Source erst gar nicht durchgelesen. :oops:
DaKirsche Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 187

Win XP Pro, SuSe Linux 7.3 - 10.2, Win 2k3 Server, Win 2000, Win NT 4.0
Delphi 2006 Pro, Java, HTML, SQL, PHP, CSS
BeitragVerfasst: Mo 12.02.07 12:49 
:autsch: Danke....hätte mir ja auch auffallen können^^ Blödes .free.....

_________________
Die simpelsten Fehler sind meist die Schwersten...