Customized Quick Report Print Save Window Quick Report 2.0 The default printed preview window is the English interface. If there is such an English version of the medium-text software, it is not existing some small shortcomings. This must now be a printed premium window in the middle interface. But it is the source code for Delphi, there is no .PAS source file, which is not straight to repair the source, and can only be self-employed. After many practices, the writer model is realized with a printed premium window with the exterior view of the default preview window. Proceed as follows:
1. Newly build a window, set up NAME for MyPreview.
2. Add a TOOLBAR control on the window, mode imitation the default preview window to create the corresponding Toolbutton, and set the HINT indication of each button.
3. Add a PANEL control, aligned to Albottom. Then put a progravelbar on this panel and Panel (right alignment), divide the report loading progress and other reporting information.
4. Add the qrpreview control, align moderate to AlClient.
5. Add OpenDialog, set the Filter property to * .q; add Savedialog, set the filter attribute to * .qr | * .csv, set the defaultExt attribute * .q.
6. Double-click each Toolbutton to enter the corresponding code code. Customized preview window can be adjusted by the following method.
Overload TQuickRep OnPreview the event, enter the following code: procedure TRptForm.RptFormPreview (Sender: TObject); begin with TMyPreview.Create (Application) do begin QRPreview1.QRPrinter: = TQRPrinter (Sender); CurRep: = self; Show; end; END;
The specific implementation of each member method: UNIT MyPRV;
Interfaceuses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, Comctrls, Toolwin, qrprntr, Quickrpt, Stdctrls, Extctrls, QRextra, QRHTML
type TMyPreview = class (TForm) QRPreview1: TQRPreview; ToolBar1: TToolBar; (rest member variable and method declarations omitted.) private {Private declarations} FPageCount: integer; // report the total number of pages public {Public declarations} CurRep: TQUickRep; // Preview report procedure updatepanelshow;
IMPLEMENTATION
{$ R * .DFM} procedure TMyPreview.UpdatePanelShow; begin // update the display Panel2.Caption: = 'on' inttostr (QRPreview1.PageNumber) 'total page' inttostr (FPageCount) 'p'; end; procedure TMYPREVIEW.TOOLBUTTON2CLICK (Sender: TOBJECT); begin file: // zoomtofit Zoom to full screen qrpreview1.zoomtofit; end;
Procedure TMYPREVIEW.TOOLBUTTON3CLICK (Sender: TOBJECT); Begin File: // ZoomTo100% Reduced to the actual small qrpreview1.zoom: = 100;
Procedure TMYPREVIEW.TOOLBUTTON4CLICK (Sender: TOBJECT); Begin File: // ZoomtowIDTH Reduced page Wide Qrpreview1.Zoomtowidth; END;
Procedure TMYPREVIEW.TOOLBUTTON6CLICK (Sender: TOBJECT); begin file: // first Page = 1; UpdatePanelShow;
Procedure TMYPREVIEW.TOOLBUTTON8CLICK (Sender: TOBJECT); begin file: // prior page qrpreview1.pagenumber 1; UpdatePanelShow;
procedure TMyPreview.ToolButton7Click (Sender: TObject); begin file: // next page QRPreview1.PageNumber: = QRPreview1.PageNumber-1; if QRPreview1.PageNumber = 0 then QRPreview1.PageNumber: = 1; UpdatePanelShow; end;
Procedure TMYPREVIEW.TOOLBUTTON9CLICK (Sender: TOBJECT); begin file: // Last Page = fpagecount; UpdatePanelShow;
Procedure TMYPREVIEW.QRPREVIEW1PAGEAVAILABLE (SENDER: TOBJECT; PAGENUM: INTEGER); begin file: // get pagecount fpagecount: = PAGENUM; UPDATELSHOW;
Procedure TMYPREVIEW.FORMCLOSE (Sender: TpoBject; var Action: tclosection); begin currep: = nil; action: = cafree;
Procedure TMYPREVIEW.TOOLBUTTON14CLICK (Sender: TOBJECT); Begin File: // Close The Window Close; End;
procedure TMyPreview.ToolButton11Click (Sender: TObject); begin file: // print setup QRPreview1.QRPrinter.PrintSetup; end; procedure TMyPreview.ToolButton13Click (Sender: TObject); begin file: // print QRPreview1.QRPrinter.Print; end;
procedure TMyPreview.ToolButton16Click (Sender: TObject); begin file: // save button if SaveDlg1.Execute then begin if (SaveDlg1.FIlterIndex <> 1) and (CurRep = nil) then Exit; case SaveDlg1.FilterINdex of 1: file: //--*.Qr qrpreview1.qrprinter.save (Savedlg1.FileName); 2: file: //-*.txt currep.exporttofilter (tqrasciiexportfilter.create (savedlg1.filename); 3: file: // . - * HTM CurRep.ExportToFilter (TQRHTMLExportFilter.Create (SaveDlg1.FileName)); 4: file: //--*.CSV CurRep.ExportToFilter (TQRCSVExportFilter.Create (SaveDlg1.FileName)); end; end; end;
Procedure tmypreview.toolbutton17click (sender: TOBJECT); begin file: // load button qrpreview1.qrprinter.load (OpenDLG1.FileName);
Procedure TMYPREVIEW.QRPREVIEW1PROGRESSUPDATE (SENDER: INTEGER); begin file: // updage programs bar programsbar1.position: = progress;
procedure TMyPreview.SaveDlg1TypeChange (Sender: TObject); begin file: // set DefaultExt property of Savedialog with SaveDlg1 do case FilterIndex of 0: DefaultExt: = '.QR'; 1: DefaultExt: = '.TXT'; 2: DefaultExt: = '.Htm'; 3: Defaultext: = '.csv'; end; end; end. // end of unit