Page 1 of 1

Canvas member ceases to exist on Export

Posted: Tue Feb 24, 2009 11:02 am
by 15050520
Hi,

I have a Tchart ActiveX control (v8) that successfully draws alarm lines on the canvas in the OnBeforeDrawSeries method in VFP 9, but when Exporting, the method returns an error saying "Member Pen does not evaluate to an object".

A call to Export is made with:-

TChart1.Export.asMetafile.SaveToFile(lcFile)

When this runs, the error occurs on the following line in the OnBeforeDrawSeries method:-

TChart1.Canvas.Pen.Width = 1

This property is available in the debugger but not when the code executes.

Your help would be greatly appreciated.

Thanks
Bruce

Posted: Wed Feb 25, 2009 3:16 pm
by yeray
Hi Bruce,

I haven't been able to reproduce the problem here. At the same time, I'd like to apologize because VFP isn't very familiar to us. So, could you please try to explain the exact steps to reproduce it here?

Thanks in advance.

Posted: Thu Feb 26, 2009 10:46 am
by 15050520
Hi Yeray,

I have a chart that displays a series of reference lines from left to right on the canvas in OnBeforeDrawSeries prior to plotting a Line series of values.

The chart displays correctly on screen even when adding or removing additional series.

However, when stepping through the code when calling EXPORT :-

(TChart1.Export.asMetafile.SaveToFile(lcFile)

(Same problem exists for Export.asJPEG)

then the values for Pen and Brush are visible but any attempt to alter them (e.g. values for Pen.Width or Brush.Color), results in the error message "Member Pen does not evaluate to an object".

The Line series all work correctly and it is only the lines on the canvas created with MoveTo(x1,y), LineTo(x2,y) statements within Tchart1.Canvas that cause a problem when setting values for either Pen or Brush.

I have moved the code from OnBeforeDrawSeries to OnAfterDraw but the same error message is returned.

Please can you advise what methods or sequence of methods, is called inherently by the EXPORT function or alternatively if there is another way to draw reference lines on the canvas that doesn't cause this error.

I hope that this is more explanatory.


Thanks & regards

Bruce

Posted: Mon Mar 02, 2009 12:19 pm
by yeray
Hi Bruce,

Thanks for the explanation but we still aren't able to reproduce your problem so, please, could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance

Posted: Tue Mar 03, 2009 11:41 am
by 15050520
Hi Yeray,

Creating a sample project is quite a major undertaking and as you are not familiar with VFP, it means that you would need runtime libraries and then would not be able to retrieve debug or error messages when it fails.

In the User Guide under Custom drawing on the Chart, reference is made to TeeChart using an internal bitmap buffer which is copied to the screen video for display. It also states that when drawing to a metafile or printing, the Chart property refers to metafile or printer Canvas objects and does not use the bitmap in these cases.

This would explain why I can see the Canvas property values in the debugger as these objects belong to the "real Chart Canvas" and not to the metafile or printer canvas objects which don't exist.

Moving the code from the OnBeforeDrawSeries outside TChart displays the custom lines & text but it does not have persistence and vanishes as soon as the screen repaints and I cannot find a way around this problem.

Regards ... Bruce