Canvas member ceases to exist on Export

TeeChart for ActiveX, COM and ASP
Post Reply
Bruce
Newbie
Newbie
Posts: 3
Joined: Mon Oct 13, 2008 12:00 am
Location: Scotland

Canvas member ceases to exist on Export

Post by Bruce » Tue Feb 24, 2009 11:02 am

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

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Feb 25, 2009 3:16 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bruce
Newbie
Newbie
Posts: 3
Joined: Mon Oct 13, 2008 12:00 am
Location: Scotland

Post by Bruce » Thu Feb 26, 2009 10:46 am

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

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Mar 02, 2009 12:19 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bruce
Newbie
Newbie
Posts: 3
Joined: Mon Oct 13, 2008 12:00 am
Location: Scotland

Post by Bruce » Tue Mar 03, 2009 11:41 am

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

Post Reply