Quickreport forum
Go to Quickreport website
Welcome Guest Search | Active Topics | Log In | Register

Custom Preview in a Panel
alberto.menghini
#1 Posted : 01 November 2018 10:46:44(UTC)
Rank: Newbie

Groups: Registered
Joined: 02/12/2016(UTC)
Posts: 2
Location: ITALY

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Good morning,
I would need to view the preview of a print within a certain panel of my main form.

Excuse my ignorance but I do not know how to do it and I need your help.

I have a custom preview form ( TASQRPreview = class(TForm) ) with this interface ( like in demo program ).

TASQRPreviewInterface = class(TQRPreviewInterface)
public
function Show(AQRPrinter : TQRPrinter) : TWinControl; override;
function ShowModal(AQRPrinter : TQRPrinter): TWinControl; override;
end;

The unit tpQuickreport below is my empty quick report I want to show in a panel ( pnREPORT = TPanel ) in my main form

// My main form

FStampa := TtplQuickReport .Create( nil, PARAMETRI, 1, 1 );
// Preview.client := pnSTAMPA; ??? How can I do that ?
// Preview.Align := alClient;
FStampa.PreviewModeless;


// report

unit tpQuickReport;

interface

uses Windows, SysUtils, Messages, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Forms, asQRPreview, apCommonSet, qrPrntr, QuickRpt, QRCtrls;

type

TtplQuickReport = class(TQuickRep)
procedure QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean);
private
public
FFromPage : integer;
FToPage : integer;
constructor Create( AOwner:TComponent; AParametri: TRecParametri; ASessione : integer = 0 ; AFromPage: integer = 1; AToPage: integer = 0 ); reintroduce; overload;
destructor Destroy; override;
end;

var
tplQuickReport: TtplQuickReport;

implementation

{$R *.DFM}

constructor TtplQuickReport.Create( AOwner: TComponent; AParametri: TRecParametri; ASessione : integer = 0 ; AFromPage: integer = 1; AToPage: integer = 0 ); reintroduce; overload;
begin
inherited Create( AOwner );
Parametri := AParametri;
FFromPage := AFromPage;
FToPage := AToPage;
RegisterPreviewClass(TASQRPreviewInterface);
end;

destructor TtplQuickReport.Destroy;
begin
inherited;
end;

procedure TtplQuickReport.QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
PrintMetafileFromPreview := true;
if FFromPage > 1 then PrinterSettings.FirstPage := FFromPage;
if FToPage > 0 then PrinterSettings.LastPage := FToPage
end;

end;
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.027 seconds.