Printing a chart into a DC

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
experten-only
Newbie
Newbie
Posts: 1
Joined: Sun Nov 02, 2003 5:00 am
Location: Linz/Austria

Printing a chart into a DC

Post by experten-only » Sat Oct 29, 2005 2:09 pm

I have a printing tool, that issues a callback when a user drawn object has to be drawn. One of these parameters is a HCD (handle to device context). Now my question:
How can I attach TeeChart to a specific Device Context or is there another possibility to do an output of a chart into a DC?

Marc
Newbie
Newbie
Posts: 4
Joined: Thu Jun 16, 2005 4:00 am
Location: Girona
Contact:

Post by Marc » Tue Nov 08, 2005 11:18 pm

Hello,
Here's an example that prints a TeeChart to a Form using the Form handle:

Code: Select all

procedure TForm1.PrintToHandle(DC: HDC; Left, Top, Right, Bottom: Integer);
var tmp:TCanvas;
SaveIndex: Integer;
begin
  tmp:=TCanvas.Create;
  SaveIndex:=SaveDC(DC);
  tmp.Handle:=DC;
  Chart1.PrintPartialCanvas(tmp,Rect(Left,Top,Right,Bottom));
  tmp.Free;
  RestoreDC(DC, SaveIndex);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  PrintToHandle(Form1.Canvas.Handle,0,0,Chart1.Width,Chart1.Height);
end;
Regards,
Marc Meumann
Steema Support

Post Reply