你可uses以下单元文件
unit Preview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin, QRPrntr, ImgList;
type
TMyPreviewForm = class(TForm)
CoolBar1: TCoolBar;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton3: TToolButton;
ToolButton5: TToolButton;
ToolButton7: TToolButton;
ToolButton9: TToolButton;
ToolButton13: TToolButton;
ToolButton15: TToolButton;
ToolButton17: TToolButton;
ToolButton19: TToolButton;
ToolButton21: TToolButton;
ToolButton2: TToolButton;
QRPreview: TQRPreview;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
ToolButton4: TToolButton;
ToolButton6: TToolButton;
procedure QRPreviewPageAvailable(Sender: TObject;
PageNum: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
procedure ToolButton9Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton13Click(Sender: TObject);
procedure ToolButton15Click(Sender: TObject);
procedure ToolButton17Click(Sender: TObject);
procedure ToolButton19Click(Sender: TObject);
procedure ToolButton21Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MyPreviewForm: TMyPreviewForm;
implementation
{$R *.DFM}
procedure TMyPreviewForm.QRPreviewPageAvailable(Sender: TObject;
PageNum: Integer);
begin
self.StatusBar1.Panels[3].Text:='总共有:'+IntToStr(QRPreview.QRPrinter.PageCount)+'页';
end;
procedure TMyPreviewForm.ToolButton1Click(Sender: TObject);
begin
QRPreview.ZoomToFit;
end;
procedure TMyPreviewForm.ToolButton3Click(Sender: TObject);
begin
QRPreview.Zoom:=100;
end;
procedure TMyPreviewForm.ToolButton5Click(Sender: TObject);
begin
QRPreview.ZoomToWidth ;
end;
procedure TMyPreviewForm.ToolButton7Click(Sender: TObject);
begin
QRPreview.PageNumber :=1;
self.StatusBar1.Panels[2].Text:= '当前页码:第1页';
end;
procedure TMyPreviewForm.ToolButton9Click(Sender: TObject);
begin
if QRPreview.PageNumber >1 then
begin
QRPreview.PageNumber:=QRPreview.PageNumber -1;
self.StatusBar1.Panels[2].Text:= '当前页码为:第'+intToStr(QRPreview.pageNumber)+'页';
end;
end;
procedure TMyPreviewForm.ToolButton2Click(Sender: TObject);
begin
if QRPreview.PageNumber<QRPreview.QRPrinter.PageCount then
begin
QRPreview.PageNumber:=QRPreview.PageNumber +1;
self.StatusBar1.Panels[2].Text:= '当前页码为:第'+intToStr(QRPreview.pageNumber)+'页';
end;
end;
procedure TMyPreviewForm.ToolButton13Click(Sender: TObject);
begin
QRPreview.PageNumber:=QRPreview.QRPrinter.PageCount;
self.StatusBar1.Panels[2].Text:= '当前页码为:第'+intToStr(QRPreview.pageNumber)+'页';
end;
procedure TMyPreviewForm.ToolButton15Click(Sender: TObject);
begin
if Opendialog1.execute then
QRPreview.QRPrinter.Load(Opendialog1.FileName);
end;
procedure TMyPreviewForm.ToolButton17Click(Sender: TObject);
begin
if Savedialog1.Execute then
QRPreview.QRPrinter.Save(savedialog1.FileName);
end;
procedure TMyPreviewForm.ToolButton19Click(Sender: TObject);
begin
QRPreview.QRPrinter.PrintSetup ;
end;
procedure TMyPreviewForm.ToolButton21Click(Sender: TObject);
begin
QRPreview.QRPrinter.Print ;
end;
procedure TMyPreviewForm.ToolButton4Click(Sender: TObject);
begin
Close;
end;
end.
然后在你所要引用的文件中加入以下代码:
procedure Tqrform.QuickRep1Preview(Sender: TObject);
begin
MyPreviewForm.QRpreview.QRprinter:=QuickRep1.QRprinter;
MyPreviewForm.Show;
end;