Autor Beitrag
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Sa 28.05.05 23:56 
Hallo Leutz

Ich bekomme immer eine Fehlermeldung wenn ich zur Laufzeit erzeugte Komponeten lösche. Diese Fehlermeldung kommt aber nur einmalig. Wenn ich die Komponenten neu erzeuge und wieder lösche, kommt der Fehler nicht mehr.

Hier mal mein Code:

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:
{ die Variablen werden global deklariert }

////////////////////////////////////////////////////////////////////////////////
procedure TMain1.NewAccountLabelClick(Sender: TObject);
var
  NEWNAME: string;
begin
  NEWNAME := '';
  NEWNAME := InputBox('Neues eMail-Konto','Bitte geben Sie einen Kontonamen ein:', '');
  if NEWNAME = '' then exit;

  // testen ob das konto schon besteht
  REGISTRY := TRegistry.Create;
  REGISTRY.RootKey := HKEY_LOCAL_MACHINE;
  if REGISTRY.OpenKey(REGMAIN, FALSE)then
    if REGISTRY.ValueExists(NEWNAME) then begin
      MessageDlg('Dieses Konto kann angelegt werden, da es schon existiert!', mtError, [mbOK],0);
      exit;
      end;
  REGISTRY.CloseKey;
  REGISTRY.Free;

  // die anzahl der bisherigen konten ermitteln
  TABCOUNTER :=  PageControl1.PageCount;

  // neues tabsheet erzeugen
  Tabsheet := TTabSheet.Create(Self); //Self = MainForm
  Tabsheet.PageControl := Main1.PageControl1;//
  Inc(TABCOUNTER, 1);
  Tabsheet.Name := 'Tabsheet' + IntToStr(TABCOUNTER);
  Tabsheet.Caption := NEWNAME;
  Tabsheet.Show;

  Panel := TPanel.Create(Self);
  Panel.Parent := Tabsheet;
  Panel.Left := ConfigPanel.Left;
  Panel.Top := ConfigPanel.Top;
  Panel.Width := ConfigPanel.Width;
  Panel.Height := ConfigPanel.Height;
  Panel.BevelInner := bvLowered;
  Panel.BevelOuter := bvRaised;
  Panel.Name := 'Panel' + IntToStr(TABCOUNTER);

  // "shape"-label erzeugen
  ShapeLabel := TLabel.Create(Self);
  ShapeLabel.Parent := Panel;
  ShapeLabel.Top := 184;
  ShapeLabel.Left := 16;
  ShapeLabel.Height := 13;
  ShapeLabel.Width := 348;
  ShapeLabel.Caption := '__________________________________________________________';
  ShapeLabel.Enabled := FALSE;
  ShapeLabel.Name := 'ShapeLabel' + IntToStr(TABCOUNTER);

  // label erzeugen zum löschen des kontos
  DeleteLabel := TLabel.Create(Self);
  DeleteLabel.Parent := Panel;
  DeleteLabel.Top := 204;
  DeleteLabel.Left := 294;
  DeleteLabel.Height := 13;
  DeleteLabel.Width := 83;
  DeleteLabel.Font.Style := [fsUnderline];
  DeleteLabel.Font.Color := clBlue;
  DeleteLabel.Caption := 'Konto löschen';
  DeleteLabel.Cursor := crHandPoint;
  DeleteLabel.OnClick := DeleteClick;
  DeleteLabel.Name := 'DeleteLabel' + IntToStr(TABCOUNTER);

  // checkbox erzeugen / konto beim checken mit einbeziehen
  CheckThisAccoutCheckBox := TCheckBox.Create(Self);
  CheckThisAccoutCheckBox.Parent := Panel;
  CheckThisAccoutCheckBox.Top := 204;
  CheckThisAccoutCheckBox.Left := 16;
  CheckThisAccoutCheckBox.Height := 28;
  CheckThisAccoutCheckBox.Width := 200;
  CheckThisAccoutCheckBox.WordWrap := TRUE;
  CheckThisAccoutCheckBox.Caption := 'Dieses Konto beim Prüfen auf neue eMails einbeziehen';
  CheckThisAccoutCheckBox.Name := 'CheckThisAccoutCheckBox' + IntToStr(TABCOUNTER);

  // Kontoname
  AcccountNameLabel := TLabel.Create(Self);
  AcccountNameLabel.Parent := Panel;
  AcccountNameLabel.Top := 32;
  AcccountNameLabel.Left := 40;
  AcccountNameLabel.Height := 13;
  AcccountNameLabel.Width := 68;
  AcccountNameLabel.Font.Style := [fsBold];
  AcccountNameLabel.Caption := 'Kontoname:';
  AcccountNameLabel.Name := 'AcccountNameLabel' + IntToStr(TABCOUNTER);

  AcccountNameEdit := TEdit.Create(Self);
  AcccountNameEdit.Parent := Panel;
  AcccountNameEdit.Top := 28;
  AcccountNameEdit.Left := 152;
  AcccountNameEdit.Height := 21;
  AcccountNameEdit.Width := 177;
  AcccountNameEdit.BevelInner := bvRaised;
  AcccountNameEdit.BevelOuter := bvLowered;
  AcccountNameEdit.BevelKind := bkTile;
  AcccountNameEdit.Name := 'AcccountNameEdit' + IntToStr(TABCOUNTER);
  AcccountNameEdit.Text := NEWNAME;

  // Pop-Host
  AccountPopHostLabel := TLabel.Create(Self);
  AccountPopHostLabel.Parent := Panel;
  AccountPopHostLabel.Top := 60;
  AccountPopHostLabel.Left := 40;
  AccountPopHostLabel.Height := 13;
  AcccountNameLabel.Width := 68;
  AccountPopHostLabel.Font.Style := [fsBold];
  AccountPopHostLabel.Caption := 'Pop-Host:';
  AccountPopHostLabel.Name := 'AccountPopHostLabel' + IntToStr(TABCOUNTER);

  AccountPopHostEdit := TEdit.Create(Self);
  AccountPopHostEdit.Parent := Panel;
  AccountPopHostEdit.Top := 56;
  AccountPopHostEdit.Left := 152;
  AccountPopHostEdit.Height := 21;
  AccountPopHostEdit.Width := 177;
  AccountPopHostEdit.BevelInner := bvRaised;
  AccountPopHostEdit.BevelOuter := bvLowered;
  AccountPopHostEdit.BevelKind := bkTile;
  AccountPopHostEdit.Name := 'AccountPopHostEdit' + IntToStr(TABCOUNTER);
  AccountPopHostEdit.Text := '';

  // Benutzername
  AccountUsernameLabel := TLabel.Create(Self);
  AccountUsernameLabel.Parent := Panel;
  AccountUsernameLabel.Top := 88;
  AccountUsernameLabel.Left := 40;
  AccountUsernameLabel.Height := 13;
  AccountUsernameLabel.Width := 68;
  AccountUsernameLabel.Font.Style := [fsBold];
  AccountUsernameLabel.Caption := 'Benutzername:';
  AccountUsernameLabel.Name := 'AccountUsernameLabel' + IntToStr(TABCOUNTER);

  AccountUsernameEdit := TEdit.Create(Self);
  AccountUsernameEdit.Parent := Panel;
  AccountUsernameEdit.Top := 84;
  AccountUsernameEdit.Left := 152;
  AccountUsernameEdit.Height := 21;
  AccountUsernameEdit.Width := 177;
  AccountUsernameEdit.BevelInner := bvRaised;
  AccountUsernameEdit.BevelOuter := bvLowered;
  AccountUsernameEdit.BevelKind := bkTile;
  AccountUsernameEdit.Name := 'AccountUsernameEdit' + IntToStr(TABCOUNTER);
  AccountUsernameEdit.Text := '';

  // Password
  AccountPasswordLabel := TLabel.Create(Self);
  AccountPasswordLabel.Parent := Panel;
  AccountPasswordLabel.Top := 116;
  AccountPasswordLabel.Left := 40;
  AccountPasswordLabel.Height := 13;
  AccountPasswordLabel.Width := 68;
  AccountPasswordLabel.Font.Style := [fsBold];
  AccountPasswordLabel.Caption := 'Passwort:';
  AccountPasswordLabel.Name := 'AccountPasswordLabel' + IntToStr(TABCOUNTER);

  AccountPasswordEdit := TEdit.Create(Self);
  AccountPasswordEdit.Parent := Panel;
  AccountPasswordEdit.Top := 112;
  AccountPasswordEdit.Left := 152;
  AccountPasswordEdit.Height := 21;
  AccountPasswordEdit.Width := 177;
  AccountPasswordEdit.BevelInner := bvRaised;
  AccountPasswordEdit.BevelOuter := bvLowered;
  AccountPasswordEdit.BevelKind := bkTile;
  AccountPasswordEdit.Name := 'AccountPasswordEdit' + IntToStr(TABCOUNTER);
  AccountPasswordEdit.Text := '';

  // prüfungsintervall                       
  AccountCheckIntervalLabel := TLabel.Create(Self);
  AccountCheckIntervalLabel.Parent := Panel;
  AccountCheckIntervalLabel.Top := 144;
  AccountCheckIntervalLabel.Left := 40;
  AccountCheckIntervalLabel.Height := 13;
  AccountCheckIntervalLabel.Width := 68;
  AccountCheckIntervalLabel.Font.Style := [fsBold];
  AccountCheckIntervalLabel.Caption := 'Prüfungsinterval:';
  AccountCheckIntervalLabel.Name := 'AccountCheckIntervalLabel' + IntToStr(TABCOUNTER);

  AccountCheckIntervalEdit := TEdit.Create(Self);
  AccountCheckIntervalEdit.Parent := Panel;
  AccountCheckIntervalEdit.Top := 140;
  AccountCheckIntervalEdit.Left := 152;
  AccountCheckIntervalEdit.Height := 21;
  AccountCheckIntervalEdit.Width := 177;
  AccountCheckIntervalEdit.BevelInner := bvRaised;
  AccountCheckIntervalEdit.BevelOuter := bvLowered;
  AccountCheckIntervalEdit.BevelKind := bkTile;
  AccountCheckIntervalEdit.Name := 'AccountCheckIntervalEdit' + IntToStr(TABCOUNTER);
  AccountCheckIntervalEdit.Text := '';

end;
////////////////////////////////////////////////////////////////////////////////
procedure TMain1.DeleteClick(Sender: TObject);
begin
  if MessageDlg('Soll das eMail-Konto '+PageControl1.ActivePage.Caption+' gelöscht werden', mtConfirmation, [mbYes, mbNo],0) = mrYes then begin
    Try
    PageControl1.ActivePage.Free; // hier kommt die Fehlermeldung !
    except {...} end;

    // die dazugehörigen registry einträge löschen
    REGISTRY := TRegistry.Create;
    REGISTRY.RootKey := HKEY_LOCAL_MACHINE;
    if REGISTRY.KeyExists(REGMAIN+PageControl1.ActivePage.Caption) then REGISTRY.DeleteKey(REGMAIN+PageControl1.ActivePage.Caption);
    REGISTRY.Free;

    end;
end;
////////////////////////////////////////////////////////////////////////////////


Vielleicht sollte ich dazusagen, die Komponeten werden entfernt, trotz der Melduung.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Mo 30.05.05 17:35 
Fehler gefunden. Es lag am zur Laufzeit erzeugten Label bzw des OnClick-Ereignis.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.