LoadChartFromStream failed in binary mode
Posted: Fri Sep 09, 2005 10:19 am
Hi,
I try to save two differents charts in a FileStream and Load these two charts with the same FileStream.
Savin g process:
procedure TForm1.SaveStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Save TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.Create(OpenDialog1.FileName,fmCreate);
SaveChartToStream(Chart1,thestream,true,false);
SaveChartToStream(Chart2,thestream,true,false);
theStream.Free;
end;
and loading process:
procedure TForm1.LoadStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Load TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.CreateOpenDialog1.FileName,fmOpenRead);
theStream.Seek(0,0);
LoadChartFromStream(TCustomChart(Chart1),theStream);
LoadChartFromStream(TCustomChart(Chart2),theStream);
Chart1.Repaint;
Chart2.Repaint;
theStream.Free;
end;
end;
This code work fine with
SaveChartToStream(Chart1,thestream,true,true);
and failed with
SaveChartToStream(Chart1,thestream,true,false);
More, if I clear chart with Chart.RemoveAllSeries after saving, the program stop after two cycles (save+load) with an access violation.
I have no event attached with charts.
Best regards
Dge
I try to save two differents charts in a FileStream and Load these two charts with the same FileStream.
Savin g process:
procedure TForm1.SaveStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Save TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.Create(OpenDialog1.FileName,fmCreate);
SaveChartToStream(Chart1,thestream,true,false);
SaveChartToStream(Chart2,thestream,true,false);
theStream.Free;
end;
and loading process:
procedure TForm1.LoadStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Load TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.CreateOpenDialog1.FileName,fmOpenRead);
theStream.Seek(0,0);
LoadChartFromStream(TCustomChart(Chart1),theStream);
LoadChartFromStream(TCustomChart(Chart2),theStream);
Chart1.Repaint;
Chart2.Repaint;
theStream.Free;
end;
end;
This code work fine with
SaveChartToStream(Chart1,thestream,true,true);
and failed with
SaveChartToStream(Chart1,thestream,true,false);
More, if I clear chart with Chart.RemoveAllSeries after saving, the program stop after two cycles (save+load) with an access violation.
I have no event attached with charts.
Best regards
Dge