Page 1 of 1

Printing of Custom Drawing on TDBChart

Posted: Tue Mar 09, 2004 8:05 am
by 8576420
:!:
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

Posted: Thu Apr 15, 2004 2:18 pm
by Pep
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 ?