Autor Beitrag
ijcro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Mi 23.08.06 13:41 
Hello,

can anybody help me, please? (Sorry for English)

How write own custom preview for QuickReport via TQRPreviewInterface, when I want show actual printer, number of copies, bins paper sizes or check duplex, all without call standard printer dialog or QRPreview.QRPrinter.PrintSetup? Or exists instant preview as demo or helper can be use as template/pattern, please?

My code as skeleton of custom preview (is designed for Quickreport 2 but works with QR 3.6 fine) is attached.

When it was migrate into Delphi 2005, often show error 1400 invalid window handle. In report layer isn't use richtext.

Can anybody any idea how repair it or suspend this uncatched error, please?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
type
  TQRCustomPreviewInterface = class(TQRPreviewInterface)
  private
    { Private declarations }
  public
    { Public declarations }
    function Show(aQRPrinter: TQRPrinter): TWinControl; override;
    function ShowModal(aQRPrinter: TQRPrinter): TWinControl; override;
  end;

type
  TCustomPreview = class(TForm)
    QRPreview1: TQRPreview;
    ...
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure QRPreview1PageAvailable(Sender: TObject; PageNum: Integer);
  private
    { Private declarations }
    fQRPrinter: TQRPrinter;
    constructor Create(aQwner: TComponent; aQRPrinter: TQRPrinter); virtual;
    ...
  public
    { Public declarations }
  end;

...

function TQRCustomPreviewInterface.Show(aQRPrinter: TQRPrinter): TWinControl;
var frm: TCustomPreview;
begin
  Result := TCustomPreview.Create(Application, aQRPrinter);
  TCustomPreview(Result).Show;
end;

function TQRCustomPreviewInterface.ShowModal(aQRPrinter: TQRPrinter): TWinControl;
begin
  Result := TCustomPreview.Create(Application, aQRPrinter);
  TCustomPreview(Result).ShowModal;
end;

...

constructor TCustomPreview.Create(aQwner: TComponent; aQRPrinter: TQRPrinter);
begin
  inherited Create(aQwner);
  fQRPrinter := aQRPrinter;
  QRPreview1.QRPrinter := aQRPrinter;
end;

procedure TCustomPreview.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if QRPreview1.QRPrinter.Status = mpBusy then
  begin
    CanClose := false;
    ShowMessage(StrCustomPreviewUnDone); //busy
  end
  else CanClose := true;
end;

procedure TCustomPreview.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ...
  fQRPrinter.ClosePreview(self);
  action := caFree;
end;

procedure TCustomPreview.FormShow(Sender: TObject);
begin
  ... //controls setup in form
end;

...

initialization
  RegisterPreviewClass(TQRCustomPreviewInterface);
end.


Best Regards

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt

_________________
ijcro