Hello Yeray,
i was close to desperation to locate the problem in my application, but now I can reproduce it.
In my application each of the 4 charts is assigned to separate page of a PageControl.
If I start the application and immediately call up the print preview before all pages have been displayed once, the print preview does not work. This only happens the first time I call it up.
To demonstrate the effect, I have modified your example programm a little:
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, VCLTee.TeEngine,
Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, Vcl.StdCtrls, VCLTee.Series,
VclTee.TeePrevi, Vcl.ComCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
BPrintPreview: TButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
procedure FormCreate(Sender: TObject);
procedure BPrintPreviewClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Charts: array of TChart;
implementation
{$R *.dfm}
procedure TForm1.BPrintPreviewClick(Sender: TObject);
var preview: TChartPreview;
begin
Charts[0].PrintProportional:=False;
Charts[1].PrintProportional:=False;
Charts[2].PrintProportional:=False;
Charts[3].PrintProportional:=False;
Charts[0].PrintMargins:=Rect(2,2,2,76);
Charts[1].PrintMargins:=Rect(2,25,2,51);
Charts[2].PrintMargins:=Rect(2,50,2,26);
Charts[3].PrintMargins:=Rect(2,75,2,2);
preview:=TChartPreview.Create(Self);
with preview.TeePreviewPanel1 do begin
Panels.Clear;
Panels.Add(Charts[0]);
Panels.Add(Charts[1]);
Panels.Add(Charts[2]);
Panels.Add(Charts[3]);
end;
preview.ShowModal;
preview.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
function CreateChart(aParent: TWinControl): TChart;
begin
Result:=TChart.Create(Self);
with Result do
begin
Parent:=aParent;
Color:=clWhite;
Gradient.Visible:=False;
Walls.Back.Color:=clWhite;
Walls.Back.Gradient.Visible:=False;
Legend.Hide;
View3D:=False;
end;
Result.AddSeries(TLineSeries).FillSampleValues;
end;
var i: Integer;
begin
SetLength(Charts, 4);
for i:=0 to 3 do
begin
Charts[i]:=CreateChart(PageControl1.Pages[i]);
with Charts[i] do Align := alClient;
end;
end;
end.
(The second problem (with the print title) we should perhaps discuss in a separate thread. I wanted to have the print title printed on the paper as well, not only on the preview panel)
Regards
Metek