I'm trying to use a constant dynamic array of TClass
but the stored values are not valid. When I use a constant static array[0..xx] of TClass
, this is correctly working.
Here is a sample code :
const
_CtrlClasses : array[0..2] of TClass
= (TPresentedTextControl,TTextControl,TCustomEdit);
_CtrlClassesDyn : array of TClass
= [TPresentedTextControl,TTextControl,TCustomEdit];
// _CtrlClasses : array[0..2] of integer
// = (1,2,3);
// _CtrlClassesDyn : array of integer
// = [1,2,3];
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
with Memo1.Lines do
begin
Add('Static :');
for i:=Low(_CtrlClasses) to High(_CtrlClasses) do Add(format('%x',[integer(_CtrlClasses[i])]));
Add('Dynamic :');
for i:=Low(_CtrlClassesDyn) to High(_CtrlClassesDyn) do Add(format('%x',[integer(_CtrlClassesDyn[i])]));
end;
end;
The result, stored in Memo1, is as follow :
Static :
79FA84
6F9C88
7F7EFC
Dynamic :
79FADC
6F9CE0
7F7F54
The correct values are the ones below "Static :". In the case of the dynamic array, an constant offset ($58) is added to the stored value.
Could you help me ?