Bonjour à tous,

j'ai une erreur bizarre qui apparait lors de l'exécution de mon programme, et je ne sais vraiment pas comment la résoudre. Elle apparaît à chaque lancement de mon appli, lors de la première instruction du constructeur.

Exception EClassNotFound dans le module toto.exe à 00013126
Class TLabel non trouvée.
Je précise que tout fonctionnait parfaitement et que je n'ai pas modifié mon code. Je le poste quand même, on ne sait jamais, mais je soupçonne fortement delphi de s'être emmelé dans son propre code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
unit UnitMainForm;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
const
  ARRAY_DEFAULT_SIZE = 5;
type
  {Exception lancée lorsque l'on cherche à assigner des valeurs négatives aux
   coordonnées d'un point}
  TNegativeIntException=class(Exception)
    public
      constructor Create(); overload;
      constructor Create(Msg:String); overload;
      constructor Create(Value:Integer); overload;
      constructor Create(Msg:String; Value:Integer); overload;
  end;
 
  {Classe représentant un point}
  TPoint = class
    private
      fx, fy:Integer;
      procedure setX(x:Integer);
      procedure setY(y:Integer);
    public
      constructor Create(); overload;
      constructor Create(x:Integer); overload;
      constructor Create(x,y:Integer); overload;
      property x:Integer read fx write setX default 0;
      property y:Integer read fy write setY default 0;
      function AsString():String; virtual;
      destructor Destroy(); override;
  end;
 
  {Classe de la fiche principale}
  TMainForm = class(TForm)
    private
      Points:array of TPoint;
      procedure InitArray(MaxVal:Integer); overload;
      procedure InitArray(MaxVal, Size:Integer); overload;
      procedure ClearArray();
      procedure Refresh();
    public
      LabelPoints: TLabel;
      LabelUsableIndex: TLabel;
      LabelRange: TLabel;
      ButtonInitArray: TButton;
      ButtonClearArray: TButton;
      ButtonRefreshForm: TButton;
      EditChoosePoint: TEdit;
      LabelChoosePoint: TLabel;
      ButtonModifyPoint: TButton;
      ButtonInsert: TButton;
      constructor Create(AOwner:TComponent); override;
      procedure ButtonInitArrayClick(Sender: TObject);
      procedure ButtonRefreshFormClick(Sender: TObject);
      procedure ButtonClearArrayClick(Sender: TObject);
  end;
 
var
  MainForm: TMainForm;
 
implementation
{$R *.dfm}
 
  {Implémentation de la classe TNegativeIntException}
  constructor TNegativeIntException.Create(); begin
      inherited Create('Vous avez introduit une valeur négative !');
  end;
 
  constructor TNegativeIntException.Create(Msg:String); begin
      inherited Create(Msg);
  end;
  constructor TNegativeIntException.Create(Value:Integer); begin
      inherited Create('Vous avez introduit une valeur négative ('+
                      IntToStr(Value)+') !');
  end;
  constructor TNegativeIntException.Create(Msg:String; Value:Integer); begin
      inherited Create(Msg+sLineBreak+'Valeur incorrecte: '+IntToStr(Value));
  end;
 
  {Implémentation de la classe TPoint}
  constructor TPoint.Create(); begin
      inherited Create();
      x := 0;
      y := 0;
  end;
  constructor TPoint.Create(x:Integer); begin
      inherited Create();
      Self.x := x;
      y := 0;
  end;
  constructor TPoint.Create(x,y:Integer); begin
      inherited Create();
      Self.x := x;
      Self.y := y;
  end;
  procedure TPoint.setX(x:Integer); begin
      if(x<0) then
        raise TNegativeIntException.Create(x);
      fx := x;
  end;
  procedure TPoint.setY(y:Integer); begin
      if(y<0) then
        raise TNegativeIntException.Create(y);
      fy := y;
  end;
  function TPoint.AsString():String; begin
      Result := 'TPoint: x='+IntToStr(x)+', y='+IntToStr(y);
  end;
  destructor TPoint.Destroy(); begin
      ShowMessage('TPoint.Destroy()');
      inherited; {TObject.Destroy();}
  end;
 
 
  {Implémentation de la classe TMainForm}
  constructor TMainForm.Create(AOwner:TComponent); begin
      inherited; // invoque TForm.Create(AOwner);
      ShowMessage('constructor TMainForm.Create(AOwner:TComponent)'); // <<=== ICI ===  //
      InitArray(10);
      Refresh();
  end;
 
  procedure TMainForm.InitArray(MaxVal:Integer); begin
      Self.InitArray(MaxVal, ARRAY_DEFAULT_SIZE);
  end;
 
  procedure TMainForm.InitArray(MaxVal, Size:Integer);
    var
      i:Integer;
    begin
      {Contrôle paramètres}
      if(MaxVal<=1)then
        raise TNegativeIntException.Create(MaxVal);
      if(Size<=0)then
        raise TNegativeIntException.Create(Size);
 
      SetLength(Points, Size);
 
      for i := Low(Points) to High(Points) do
        Points[i] := TPoint.Create(random(MaxVal), random(MaxVal));
 
      ShowMessage('Array inited: '+IntToStr(Size)+' new points between 0 and '
                  +IntToStr(MaxVal)+' created !');
  end;
 
  procedure TMainForm.ClearArray(); begin
      Finalize(Points);
      ShowMessage('Points cleared !');
  end;
 
  procedure TMainForm.Refresh();
    var
      i:Integer;
      s:String;
    begin
      if Low(Points) > High(Points) then
        s := '(aucun point)'
      else
        s := '('+IntToStr(Low(Points))+' - '+IntToStr(High(Points))+')';
 
      LabelRange.Caption := s;
 
      s := '';
 
      for i := Low(Points) to High(Points) do
        s := s + sLineBreak + IntToStr(i)+ '>> ' + Points[i].AsString();
 
      LabelPoints.Caption := s;
      ShowMessage('Form Refreshed !');
  end;
 
  procedure TMainForm.ButtonInitArrayClick(Sender: TObject); begin
      InitArray(100);
  end;
 
  procedure TMainForm.ButtonRefreshFormClick(Sender: TObject); begin
      Refresh();
  end;
 
  procedure TMainForm.ButtonClearArrayClick(Sender: TObject); begin
      ClearArray();
  end;
end.
Est-ce que quelqu'un a déjà rencontré le même problème ? Comment le résoudre ? Je n'ai pas envie de recommencer un nouveau projet à chaque fois !


Merci d'avance