Page 1 of 1

SaveToStream - Non TChart Components stored, too ?

Posted: Tue Jul 03, 2007 7:34 am
by 9349911
Hi !

Have a look at the following picture:
Image

As you can see there is a Tchart called MainChart. And we place a WPTools WPRichTextLabel on the TChart compoment. We want to view some special information with it.

In some cases we got Exceptions like "EClassNotFound : Class TWPRichTextLabel not found".
I have to say that for now the RichTextLabel isn´t used in any way!

Is it possible that TChart tries to save the WPRichTextLabel as well ?

We got trouble in the methode:

Code: Select all

Procedure LoadChartFromStreamCheck( Var AChart:TCustomChart;
                                    AStream:TStream;
                                    ACheckError:TProcTeeCheckError=nil;
                                    TryReadData:Boolean=False);
It was this line that produces the error:
" Reader.ReadRootComponent(AChart);"

If we delete the WPRichTextLabel all works fine. And keep in mind. The WPRichTextLabel is unused! It is only placed on top of the TChart.

Posted: Thu Jul 05, 2007 5:56 am
by 9349911
Hi Support,

I know you have a lot of work with helping here. But could you please give me a solution / hint for this issue?
It´s really important to us.

Posted: Thu Jul 05, 2007 7:28 am
by narcis
Hi Dominik,

I'm afraid this is not possible using TeeChart saving methods. Maybe you could try creating your own object saving methods where it's saved which objects are in your form and it's hierarchy. Maybe even VCL provides methods for that.

Posted: Thu Jul 05, 2007 7:36 am
by 9349911
hi Narcís,
I'm afraid this is not possible using TeeChart saving methods.
Well that´s exactly what we know.

Maybe I have to ask in another way ...
How is it possible that TChart ignores such components? That´s the key problem. We don´t want to save the RichEdit with the TChart Methods.

Posted: Fri Jul 06, 2007 5:47 pm
by Marjan
Hi.

One dirty solution might be to:
a) Make a list of all components with Parent property equal to Chart1.
b) Prior to using any of chart saving methods, set the component(s) Parent to nil (or something else than Chart1). This should make all these components "invisible" to chart saving methods i.e. you'll be only saving chart and it's properties.
c) After loading "clean" chart, reconnect all components from (a) back to Chart1 by setting their Parent property.

Another solution might be to manually register your component class prior to using LoadChartFromFile (or LoadChartFromStream) routine. Something like this:

Code: Select all

RegisterClass(TWPRichTextLabel);
LoadChartFromFile('c:\temp\test.tee');
I haven't tested this but in theory it should work fine.