My program uses a TIniPropStorage to save some data in an INI-file. This works fine for objects which are created by the object inspector and for "normal" variables like integers, but not for an array of TColorBoxes.
My code looks like:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
IniPropStorage, ColorBox;
type
ColorBoxArray = array of TColorBox;
{ TForm1 }
TForm1 = class(TForm)
ColorBox1: TColorBox;
IniPropStorage1: TIniPropStorage;
procedure FormCreate(Sender: TObject);
private
CB: ColorBoxArray;
FField1: Integer;
public
published
property CBA: ColorBoxArray read CB write CB;
property Field1: Integer read FField1 write FField1;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
Field1:=55;
SetLength(CB,3); // is 20 in my real program
for i:=0 to High(CBA) do
begin
CBA[i]:=TColorBox.Create(self);
CBA[i].Top:=10;
CBA[i].Left:=i*120;
CBA[i].Parent:=self;
end;
Form1.SessionProperties:='Top;Left;ColorBox1.Selected;'
+ 'CBA[1].Selected;CBA[2].Selected;CBA[3].Selected;Field1;'
end;
end.
It compiles and shows no runtime error, but my INI-file contains only:
[TApplication.Form1]
Form1_Top=344
Form1_Left=329
ColorBox1_Selected=32768
Form1_Field1=55
So it works for ColorBox1 (created by the object inspector) and for Field1 (integer variable), but not for array CBA[]. Can please somebody tell me what I am doing wrong? I attached a small demo project. Thanks in advance.
I use FPC 3.0.0 with Lazarus 1.6.2 on Windows 7.