Printing of Custom Drawing on TDBChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Elli
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: Germany
Contact:

Printing of Custom Drawing on TDBChart

Post by Elli » Tue Mar 09, 2004 8:05 am

:!:
Hello NG,

We have a TDBChart with severall TFastline displaying data. On the Canvas of the chart we also have some custom drawing we need to get printed on the same page as the TDBchart.
For the printout we are using the following code:

if PrintDialog1.Execute then begin
DBChart1.BevelOuter := bvNone;
OldColor := DBChart1.Color;
DBChart1.Color := clNone;
tmpMeta := DBChart1.TeeCreateMetafiletrue,DBChart1.ClientRect);
try
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,Printer.PageHeight-1),tmpBMP);
finally
Printer.EndDoc;
end;
finally
tmpMeta.free;
DBChart1.BevelOuter := bvRaised;
DBChart1.Color := OldColor;
end;
end;

The Metafile and printout is only containing the TDBchart, the custom drawing is vanished. The custom drawing is done in the AfterDraw Event of the chart, and in the OnBeforeDrawSeries Event.

If any one has an idea i would be gratefull

Greetings Michael
Michael Ellermann
Levatum Softawre AG
Michael.Ellermann@levatum.de

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 15, 2004 2:18 pm

Hi Michael,

strange... it should work. Basically you're creating a metafile with the same size as original chart.
The consequence of this is the position of the custom objects on Canvas will be valid for metafile as well. Then you use StretchDraw method to "paint" this image (with correct text position) directly onto Printer.Canvas.
Also, you should change the following line :
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,Printer.PageHeight-1),tmpBMP);
by :
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,Printer.PageHeight-1),tmpMeta);

If you still having problems, could you please post a simple example to the public.steema.attachments newsgroups with which I can reproduce the problem "as-is" here ?

Post Reply