附各成員方法的具體實現:
unitMyprv;
interface
uses
Windows,Messages,SysUtils,Classes,Graphics,Controls, Forms,Dialogs,ComCtrls,ToolWin,qrprntr,Quickrpt,StdCtrls, ExtCtrls,qrextra,qrHtml;
type
TMyPrevIEw=class(TForm)
QRPreview1:TQRPrevIEw;
ToolBar1:TToolBar;
(其余成員變量和成員方法聲明略。)
private
{Privatedeclarations}
FPageCount:integer;// 生成報表的總頁數
public
{Publicdeclarations}
CurRep:TQuickRep; //所預覽的報表
procedureUpdatePanelShow;
end;
implementation
{$R*.DFM}
procedureTMyPrevIEw.UpdatePanelShow;
begin//更新顯示
Panel2.Caption:=第+inttostr(QRPrevIEw1. eNumber)+ 頁總+inttostr(FPageCount)+頁;
end;
procedureTMyPrevIEw.ToolButton2Click(Sender:TObject);
begin//ZoomToFit縮放至全屏
QRPrevIEw1.ZoomToFit;
end;
procedureTMyPrevIEw.ToolButton3Click(Sender:TObject);
begin//ZoomTo100%縮放至實際大小
QRPrevIEw1.Zoom:=100;
end;
procedureTMyPrevIEw.ToolButton4Click(Sender:TObject);
begin//ZoomToWidth縮放至頁寬
QRPrevIEw1.ZoomToWidth;
end;
procedureTMyPrevIEw.ToolButton6Click(Sender:TObject);
begin//Firstpage
QRPrevIEw1.PageNumber:=1;
UpdatePanelShow;
end;
procedureTMyPrevIEw.ToolButton8Click(Sender:TObject);
begin//priorpage
QRPreview1.PageNumber:=QRPrevIEw1.PageNumber+1;
UpdatePanelShow;
end;
procedureTMyPrevIEw.ToolButton7Click(Sender:TObject);
begin//nextpage
QRPreview1.PageNumber:=QRPrevIEw1.PageNumber1;
ifQRPrevIEw1.PageNumber=0then
QRPrevIEw1.PageNumber:=1;
UpdatePanelShow;
end;
procedureTMyPrevIEw.ToolButton9Click(Sender:TObject);
begin//Lastpage
QRPrevIEw1.PageNumber:=FPageCount;
UpdatePanelShow;
end;
procedureTMyPreview.QRPrevIEw1PageAvailable(Sender:TObject; PageNum:Integer);
begin//getpagecount
FPageCount:=PageNum;
UpdatePanelShow;
end;
procedureTMyPrevIEw.FormClose(Sender:TObject;varAction:TCloseAction);
begin
CurRep:=nil;
Action:=caFree;
end;
procedureTMyPrevIEw.ToolButton14Click(Sender:TObject);
begin//closethewindow
Close;
end;
procedureTMyPrevIEw.ToolButton11Click(Sender:TObject);
begin//printsetup
QRPrevIEw1.QRPrinter.PrintSetup;
end;
procedureTMyPrevIEw.ToolButton13Click(Sender:TObject);
begin//print
QRPrevIEw1.QRPrinter.Print;
end;
procedureTMyPrevIEw.ToolButton16Click(Sender:TObject);
begin//savebutton
ifSaveDlg1.Executethen
begin
if(SaveDlg1.FIlterIndex $#@60;$#@62;1)and(CurRep=nil)then
Exit;
caseSaveDlg1.FilterINdexof
1://*.QR
QRPrevIEw1.QRPrinter.Save(SaveDlg1.FileName);
2://*.TXT
CurRep.ExportToFilter(TQRAsciIExportFilter.Create(SaveDlg1.FileName));
3://*.HTM
CurRep.ExportToFilter(TQRHtmlExportFilter.Create(SaveDlg1.FileName));
4: //*.CSV
CurRep.ExportToFilter(TQRCSVExportFilter.Create(SaveDlg1.FileName));
end;
end;
end;
procedureTMyPrevIEw.ToolButton17Click(Sender:TObject);
begin//loadbutton
ifOpenDlg1.Executethen
QRPrevIEw1.QRPrinter.Load(OpenDlg1.FileName);
end;
procedureTMyPreview.QRPrevIEw1ProgressUpdate(Sender:TObject; Progress:Integer);
begin//updageprogressbar
ProgressBar1.Position:=Progress;
end;
procedureTMyPrevIEw.SaveDlg1TypeChange(Sender:TObject);
begin//setDefaultExtpropertyofSavedialog
withSaveDlg1do
caseFilterIndexof
0: DefaultExt:=.QR;
1: DefaultExt:=.TXT;
2: DefaultExt:=.HTM;
3: DefaultExt:=.CSV;
end;
end;
end.//endofUnit