Page 1 of 1

VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Posted: Mon Sep 20, 2010 5:29 pm
by 16856806
Hi,

I am using TeeChart Standard 9 and facing an issue with saving and loading charts from a TStream object. Upon loading from a TStream object using the LoadChartFromStream I get a runtime ChartException indicating "Wrong *.tee file format". Can someone help me figure out what's wrong in the code below?

Code: Select all

#include "export_chart_sample.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Chart"
#pragma link "Series"
#pragma link "TeEngine"
#pragma link "TeeProcs"
#pragma link "TeeStore"
#pragma link "TeeEdiSeri"
#pragma link "TeExport"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
   TStringStream * myStream = new TStringStream();
   SaveChartToStream(Chart1, myStream);
   LoadChartFromStream(static_cast<Chart::TCustomChart*>(Chart1), myStream);
}
Thanks,

Sajjad

Re: VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Posted: Tue Sep 21, 2010 2:02 pm
by 10050769
Hello sajtab,

I think that you need to set myStream.Position := 0 before reading from it . Next lines of code explains exactly, how you do to load stream:

Code: Select all

 1) Save the template into a Stream...
  TMemoryStream *tmp = new TMemoryStream();
 
    // save only Chart and Series formatting, not data
    SaveChartToStream(TemplateChart,tmp,false);

    // 2) Load the template...

    // Reset stream position to begin:
    tmp->Position=0;

    // Load chart reference from stream:
    LoadChartFromStream(dynamic_cast<TCustomChart*>(Chart1),tmp);
Could you please, say us if previous code solve your problem?

I hope will helps.

Thanks,

Re: VCL2010 LoadChartFromStream Issue: "Wrong *.tee file format"

Posted: Tue Sep 21, 2010 9:48 pm
by 16856806
Thank you very much for your help. Not resetting the TStream objects Position field to 0 was the problem.

Sajjad