narcis wrote:Hi Messie,
Yes, you should use this code on TChart's OnAfterDraw event so the custom painting is done every time the chart is repainted.
I tried that, but I first have the problem that the chart is not displayed on the screen but printed to a printer canvas. So the AfterDraw is not hooked until the printing is done.
So I need a better way to trigger the Drawing manually than painting the graph to a dummy canvas.
Second is, that the chart.canvas.handle is changed when the OnAfterDraw event is triggered.
Code: Select all
Form := TTntForm.Create(Application);
Graph := TChart.Create(Form);
Graph.Parent := Form;
Graph.OnAfterDraw := ObjectUtils.ChartAfterDraw;
...
GraphHandle := Graph.Canvas.Handle;//global buffer
Graph.PaintTo(Form.Canvas,0,0);
...
PrintCanvas.Draw(0,0,graph.TeeCreateMetafile(false,rect));
GraphHandle := Graph.Canvas.Handle; //now it's different
Does the canvas need an own reference when it is created at runtime?
I tested an example using a chart on a visible form and the canvas.handle changes again. Is the canvas recreated at each repaint?
Thanks, Ulfert