Quick Report FAQ [ 3 ]

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
[Multiple Columns]
==================
Q. Is it possible to set the width of each column if the page has 4 columns ?
A. The width of the column is the determined by the number of columns divided by the page width, then subtract the report.page.columnwidth value. You can not set the width of a band directly.
------------------
Q. When I create multi-column report, second, third etc. columns overwrite children of the title band.
A. This is a known bug with QuickReport 2. One work around be to use a pageheader band with child bands. Since the page header prints after the title, you would put the actual page header information on the last child band and use the preceding page header (and children) for the title information. In the BeforePrint events for the bands, you would set PrintBand to false when the page number was greater than 1.
(QR3) This has been fixed with QuickReport 3
------------------
Q. I have a multiple column report where I want to have two groups, one that forces a page break, and one that forces a column break. I can set this just fine. But what happens is when I get the page break, the data prints in the second column of the report and the first column is blank. Is there a way to suppress the column break after a page break?
A. What you need to do is to set the 2nd group's ForceNewColumn property to false the first time the group is printed on each page. Then set it back to true to handle the reset of the page. Set the property to false in the report's OnStartPage event, which gets called at the start of each page. In the AfterPrint event of the group band, set the property to True so it will work the next time it's called on that page.
------------------
Q. I am interested in adding the capability of generating mailing labels to my current application. I could not find any information about mail labels in your documentation.
A. Doing labels is pretty straight forward. You set the detailband's height or Size.Height properties to fit the height of your labels and then set the report's Page.Columns property to the number of labels that would go across the page. You may need to adjust the top and bottom margins of the page to fit your labels.
------------------
Q. Is there a way to make QReports print columns Left to Right - Top to Bottom instead of Top to Bottom - Left to Right?
A. This is scheduled for a future QuickReport release. One work around would be to use multiple sets of TQRLabel controls on a single column detail band. You would call the report's dataset.next method in the detailband's BeforePrint event and assign the values to the TQRLabels.
------------------
Q. When I do a multiple column report, the detail bands print on the same line as the group bands
A. Group bands are the same width as the detail bands and since the columns go down then across, it is possible to have detail bands at the same vertical position (different horizontal position) as group band. If you want column headers to stay above the detail bands, use the page header to store the header fields.
------------------
Q. I have a multiple column report that uses subdetail bands but doesn't have a detail band. I get an exception in the TQRCustomBand.GetBandSize function when I try to run the report.
A. You must have a detail band for multiple column reports. This is a known bug and will be addressed in a future release. If your report does not require a detail band, then just set it's height to 0.
------------------
[NeedData]
==========
Q. How can I update the progress display when I use OnNeedData to populate the report?
A. You can set the report's QRPrinter.Progress property in the report's OnNeedData event. The value should be in the range of 1 to 100.
Example: QuickRep1.QRPrinter.Progress := (Longint(CurrentIndex) * 100) div MyTotalCount;
------------------
Q. How do I use the OnNeedData event?
A. When you define this event, it will get called to see if a new detail line is needed. It has a boolean variable named MoreData. Set it to true if you still have data and false when you are done. The QR3DEMO project on our download page has examples of how to use this.
------------------
Q. I am using the onNeedData event to fill a report, and I noticed that the last "record" doesn't show on the preview, and it doesn't print.
A. In your OnNeedData event, are you setting MoreData to false on the last record? That would suppress the last record, you want to set MoreData to false in the OnNeedData event that gets called after the last detail band has printed.
------------------
Q. How can I build a report with data that doesn't come from a BDE table or query?
A. QuickReport was designed to work with BDE datasources, but it can use data from other sources via the OnNeedData events. Please see the manual topic for OnNeedData for more information.
------------------
Q. The output from preview is correct, but printing from the preview does not print all of the data or the data has values from the last run of the report.
A. If the problem is only when you print from a preview, then you will need to reset your data (datasets and/or variables) in the BeforePrint event of the QuickReport. This event gets called whenever the report needs to be generated.
When the report is regenerated, sometimes you will have to reset your dataset. One example is if the dataset has a memo and you are connected to a SQL database server like Oracle. The problem seems to be in the BDE's BLOB caching.
Another situation would be if you are using OnNeedData and that event is controlled by a variable that needs to be initialized at the start of the report.
------------------
 
[Paper size issues]
==================
Q. If the Quickreport.Page.TopMargin is to small then the Top of the Quickreport is not be printed. Quickreport should tell the user that the Quickreport is out of printable range
A. This is being considered for a future release.
------------------
Q. How do I set the paper size?
A. For detailed information about setting the paper size, please refer to the section on Paper size and Margins (page 2-21) in the QuickReport 2 manual. This manual comes with QuickReport under the filename qr2.doc.
------------------
Q. How do I determine the default paper size of the selected printer?
A. The following code checks the printer to see what paper size is the default.
with TQRPrinter.Create do
begin
PrinterIndex := QuickRep1.PrinterSettings.PrinterIndex;
{ for the default printer use the following line }
PrinterIndex := -1;
QuickRep1.Page.PaperSize := Papersize;
free;
end;
------------------
[Preview]
==================
Q. I create my reports using this method:
QuickReport.Prepare;
QuickReport.QRPrinter.Preview
QuickReport.QRPrinter.Free;
QuickReport.QRPrinter := nil;
Now the navigation buttons in the print preview do not work.
A. When used with Prepare, the Preview method returns immediately. This code would have freed the data being used by the preview. The Free and Nil lines should be removed. If you want the code to wait until after the preview has executed, just put a wait loop that waits until the qrprinter has been freed:
Example:
repeat
Application.ProcessMessages
until QuickRep1.QRPrinter = nil;
------------------
Q. In Quick Report 3, Composite Reports do not have an "OnPreview" event. Is there a was to use TQRPreview with Composite Reports?
A. The OnPreview event was left in for compatibility with Quick Report 2. With Quick Report 3, it is very easy to register a custom preview as the default preview for all reports. There are detailed examples of how to do this in the QR3MDID4.ZIP and QR3RNGD4.ZIP demo projects on our download page.
Example code from the demos..
type
// To have a custom preview be used as the default preview,
// you first define an interface class. You will provide two
// functions for this class, Show, and ShowModal.
// don't forget to add qrprntr to the uses clause of this unit.
TQRSimplePreviewInterface = class(TQRPreviewInterface)
public
function Show(AQRPrinter : TQRPrinter) : TWinControl; override;
function ShowModal(AQRPrinter : TQRPrinter): TWinControl; override;
end;
implementation
function TQRSimplePreviewInterface.Show(AQRPrinter : TQRPrinter) : TWinControl;
begin
Result := TPreviewForm.CreatePreview(Application, AQRPrinter);
TPreviewForm(Result).Show;
end;
function TQRSimplePreviewInterface.ShowModal(AQRPrinter : TQRPrinter) : TWinControl;
begin
Result := TPreviewForm.CreatePreview(Application, AQRPrinter);
TPreviewForm(Result).ShowModal;
end;
To specify this preview as the default, you would call the RegisterPreviewClass with the type of preview to register:
RegisterPreviewClass(TQRSimplePreviewInterface);
If you are using custom previews designed with Quick Report 2, there were changes made to how the preview's FormClose event works. Please see the standard preview's FormClose code. If you use the Quick Report 2 Preview's FormClose code, it will not free the qrprntr object created by the report.
------------------
Q. Is there a way to close any open preview forms through code?
A. You can loop through the list of forms and find each preview form by the class name and then close it.
Example:
for nIdx := (Screen.FormCount - 1) downto 0 do
with Screen.Forms[nIdx] do
if ClassName = 'TQRStandardPreview' then <-- Substitute or add your class for custom previews
Close;
------------------
Q. How can I implement a modal preview? The standard preview isn't modal, when the user make it smaller and click on another form the preview form is hidden. Is there a way to show the preview modal?
A. Quickreport 2 requires a non-modal preview form to allow the report to process the data. What you can do is use a custom preview and set it's form style to fsStayOnTop, that would keep the users in the preview until they close it.
(QR3) QuickReport 3 (3.0.1 or newer) has some additional preview methods, PreviewModal and PreviewModeless. These two methods run in a thread and can not be used with non-thread safe database drivers (like SQL Links). This limitation will be addressed in a future release.
------------------
Q. Is it possible to set preview "Fit To Page" as default when opening the preview of a report ?
A. You can modify the source code for the default preview, or build a custom preview that has this behavior. We have a sample project for custom previews on our download page that shows how to specify the starting zoom setting for the preview.
------------------
Q. When repeatedly previewing a report and closing BEFORE the first page is displayed, there is a access violation.
A. If you are using a custom preview, you must make sure that you have set the qrpreview's qrprinter property to nil when you close the preview. If you are repeatedly calling preview or print, you may to add code to check the report's state property. When it's set to qrAvailable (defined in quickrep.pas), then the report is safe to call.
------------------
Q. Can I preview only selected pages?
A. There isn't any easy way to preview a range of pages. As each page is rendered, the preview is notified that the page is now available. You could have to modify the report to stop after a certain page, but there isn't any way to tell the preview to start at a specific page.
------------------
Q. Why doesn't the printersetup button work from the preview when I load a saved report?
A. This is actually a design feature. When the orientation or paper size was changed, the result was poor output from the saved repots so this functionality was removed from the default preview. If you build a custom preview, you can use the printersetup on saved reports. Example projects with a custom preview with this functionality can be downloaded from our download page under the filename custprev.zip (QuickReport 2) and QR3CSTD3.ZIP (QuickReport 3)
------------------
Q. We've a problem with QRPrinter.PageCount. We've created our own Previewform and when we call QRPrinter.PageCount we always get 0. What's wrong??
A. You need to specify the preview's qrprinter, otherwise the global qrprinter will be used. Also, the total page count is not known when the preview is first shown, you must use the preview's OnPageAvailable to update the page count as each page is rendered.
Example:
procedure TfrmPreview.QRPreviewPageAvailable(Sender: TObject;
PageNum: Integer);
begin
if PageNum = 1 then
Caption := QRPreview.QRPrinter.Title + ' - 1 page'
else
Caption := QRPreview.QRPrinter.Title + ' - ' + IntToStr(PageNum) + ' pages';
case QRPreview.QRPrinter.Status of
mpReady: Caption := Caption + ' READY';
mpBusy: Caption := Caption + ' BUSY';
mpFinished: Caption := Caption + ' FINISHED';
end;
end;
------------------
Q. If I change the Paper Size in the Printer Setup of the preview, the report does not reflect the size selected.
A. This is a known issue and will be addressed in a future release. The work around would be to provide a selection of available page sizes to user before you run the report and the set the report's Page.PaperSize property to paper selected.
------------------
Q. My custom preview does not use the zoom value that I set at design time, how do I get it to start up with the value that I want?
A. When the QRPreview is created, it defaults with a zoom value of 100, you'll need to set the value after you create the QRPreview.
------------------
Q. How can I augment the preview's print function to display a dialog box after the report prints?
A. The default preview wont let you do this, but if you create a custom preview for your report, you can call the dialog after printing.
An example print button event could look like this:
procedure TfrmPreview.PrintClick(Sender: TObject);
begin
Print.Enabled := False;
QRPreview.qrprinter.Print;
Print.Enabled := True;
MessageDlg('Did we print?', mtconfirmation, [mbOk], 0);
end;
------------------
Q. How can I determine the number of pages in my report before I preview or print it?
A. If you call the report's Prepare method, it will generate the report without printing or previewing it. After Prepare has finished, the pagecount will be in the report's qrprinter.pagecount property. Please refer to the manual topic on Prepare for more information.
Example:
QuickRep1.Prepare;
QuickRep1.ReportTitle := 'This report has ' +
IntToStr(QuickRep1.QRPrinter.PageCount) + ' pages';
QuickRep1.QRPrinter.Free;
QuickRep1.QRPrinter := nil;
QuickRep1.Preview;
------------------
Q. How can I have my custom preview print a range of pages without going through the printersetup dialog?
A. What you need to do is to add a public property of your preview form of type TQuickRep like the following:
type
TfrmPreview = class(TForm)
QRPreview: TQRPreview;
.....
public
{ Public declarations }
CurrentReport : TQuickRep;
end;
In the OnPreview event of the report, you would use something like:
procedure TfrmMyReport.QuickRep1Preview(Sender: TObject);
begin
with frmPreview do
begin
CurrentReport := QuickRep1;
QRPreview.QRPrinter := TQRPrinter(Sender);
Show;
end
end;
That lets you reference the calling report through the preview's CurrentReport variable. Then to print out a range of pages with out going through the printer setup, you would do something like the following:
with CurrentReport.PrinterSettings do
begin
{ To set your own printer }
PrinterIndex := MyDesignatedPrinterIndex;
{ set the page range }
FirstPage := MyDesignatedFirstPage;
LastPage := MyDesignatedLastPage;
end;
QRPreview.qrprinter.Print;
With Quick Report 3, the Master property of the qrprinter is the report that owns it.
------------------
Q. I can't get the cursor to display as an hourglass during custom preview processing.
A. This is a known issue and will be addressed in a future release
------------------
Q. I am using custom preview and want to know if there is an easy way to know when the report is done being generated?
A. When the report is done, the preview's qrprinter.status property will be set to mpFinished. The following code will display the title, total pages, and status as the preview caption when used as the preview's OnPageAvailable event.
procedure TfrmPreview.QRPreviewPageAvailable(Sender: TObject;
PageNum: Integer);
begin
if PageNum = 1 then
Caption := QRPreview.QRPrinter.Title + ' - 1 page'
else
Caption := QRPreview.QRPrinter.Title + ' - ' +
IntToStr(PageNum) + ' pages';
case QRPreview.QRPrinter.Status of
mpReady: Caption := Caption + ' READY';
mpBusy: Caption := Caption + ' BUSY';
mpFinished: Caption := Caption + ' FINISHED'; { <-- all done }
end;
end;
------------------
Q. Why in report preview mode, does the CPU usage for the quick-reports application go to 100%
A. This was a known issue and was addressed in the 2.0j release.
------------------
Q. My custom preview doesn't work the way it did with QR1
A. The preview must be called with Show instead of ShowModal. This a change from the QuickReport 1 behavior, but is required for QuickReport 2. We are considering adding a modal preview for QuickReport 3.0
------------------
Q. Why wont the progress bar work properly with non-BDE reports?
A. QuickReport 2 checks the TTable or TQuery for the current record number and the total number of records. These two values are used for displaying the progress bar percentage. SQL based queries and non-BDE data have no way of telling QR2 what the total number of records is, which is why the progress bar does not update for those kinds of reports
------------------
Q. Some computers do not display a report and others work fine.
A. We have seen that happen on machines that do not have a default printer defined. Without a default printer, QR has no way of knowing how to render the report.
------------------
Q. When the preview method of a report is called, it looks like the report is being painted twice and there is some flicker
When a form is created the event handlers are executed in the following order:
OnCreate OnShow OnPaint OnActivate OnResize OnPaint again
A. This is a known issue and will be addressed with a future release.
------------------
Q. In QR1, I could disable/hide爐he save, print and load report speed buttons in the preview. Is this no longer an option?
A. This is not an option with QuickReport 2. You would have to create a custom preview and build it with only the functionality that you require for your application. We have examples on our download page of custom previews for both Quick Report 2 and Quick Report 3
------------------
Q. Some lines do not appear in the preview, but they appear in the printout.
A. The report is rendered to a TMetafile object when it is sent to the preview. Depending on the zoom value of the preview, the scaling of the TMetafile may crop out some of the lines. If you zoom in (you may need to use a custom preview to zoom in close enough), the lines will reappear.
------------------
Q. How can I tell in BeforePrint if I am Printing or Previewing?
A. In the report's BeforePrint event, you can check the value of the report's QRPrinter.Destination property. If it's set to qrdMetafile, then it's rendering the preview. If it's set to qrdPrinter, then it's rendering the report directly to the printer. This only works when you are generating a report, if you load a saved report, the destination will always be qrdMetafile.
------------------
Q. Is there a way to tell QuickReport that when you generate a preview, you only want the preview to span a certain number of pages or have a starting/ending page number?
A. You can't tell the preview to start at a specific page, but you can get it to stop after a specified number of pages. You can use the OnEndPage event (documented in the manual) to get the report to stop processing after the specified number of pages. If you do this an extra blank page will be generated, there isn't much you can do to get around that. The following example shows how to stop the preview after only 32 pages without affecting the number pages when you print from the preview:
procedure TfrmSomeReport.QuickRep1EndPage(Sender: TQuickRep);
var
nIdx: integer;
begin
{
This code will only take affect when previewing, you will need to
add qrprntr to the uses clause.
}
if QuickRep1.QRPrinter.Destination = qrdMetafile then
if QuickRep1.PageNumber = 2 then
begin
{
Disable the printing of all bands, requires 2.0J or later.
If you do this, remember to re-enable the bands in the reports
BeforePrint event the next time you run the report.
}
for nIdx := 0 to QuickRep1.BandList.Count - 1 do
TQRCustomBand(QuickRep1.BandList[nIdx]).Enabled := false;
{
Tell the report that we are done reading data.
}
QuickRep1.qrprinter.cancel;
end;
end;
Make sure to have the following code in the report's preview to re-enable the bands again.
procedure TfrmSomeReport.QuickRep1BeforePrint(Sender: TQuickRep;
var PrintReport: Boolean);
var
nIdx: integer;
begin
for nIdx := 0 to QuickRep1.BandList.Count - 1 do
TQRCustomBand(QuickRep1.BandList[nIdx]).Enabled := true;
end;
------------------
[Printing and PrinterSetup]
==================
Q. My users can't print under NT 4, but I can as the administrator.
A. The following was taken from Hp's tech support web site, use at your own risk.
Windows NT 4.0 has the ability to control access to the hard drive by using NTFS. This local hard drive security is not available if the system is using a standard file allocation table (FAT). When the default NTFS permissions are changed to lock the system, the user may have difficulty accessing the printer. Usually the system administrator can print to the printer without any problems, but when a user logs into the system and tries to print, error messages appear and the printer fails to respond. This is often caused by the user not having the appropriate permissions to access the necessary files for the print operations. A system administrator must change the permissions to allow the user access to these files.
The following steps may provide a workaround without the System Administrator making any changes to the system security settings.
1. Select Start, Settings, and then Printers.
2. In the Printers folder, right-click the specific printer icon.
3. Verify that Default printer is checked and then click Properties.
4. Select the Securities tab, and then click the Permissions box in the Permissions window.
5. Set the permissions level, as shown below for each item.
a. Administrators--Full Control
b. CREATOR OWNER--Manage Documents
c. Everyone--Manage Documents
d. Power Users--Manage Documents
6. Set the level by selecting the name; then, using the down arrow in the Type of Access window, select the Access level.
7. This should enable users to print without errors.
------------------
Q. I am trying to print a report on a HP5P using a top margin of 4mm, but only the first page comes out.
A. We have had reports of a problem with the driver for the HP5P where it could not handle that margin size. The work around would be to use the HP6 driver with this printer.
------------------
Q. The report title is being truncated in the Windows Print Manager.
A. This is not a QuickReport bug, it is a VCL bug. If you look at the source code, we define the ReportTitle as string. It gets passed to the TQRPrinter.Title property, which is also defined as string. We pass that the TPrinter.Title property and it gets used in TPrinter.BeginDoc where it passed to CTitle, which is an array of 32 bytes. This issue was addressed in Delphi 5.
------------------
Q. When I set the page range the report continues processing until I press cancel. Only the pages selected print and that is what I want, but why does it continue to process?
A. That is a limitation of the current design of QuickReport and will be addressed in a future release.
------------------
Q. We are trying to print reports in TEXT mode (in a dot matrix printer). When we use the Generic/Text Only printer from Windows it works, but it only prints the first 80 characters of each row. What can we do to print all the characters from the row?
A. That is the designed behavior of the Generic/Text Only printer driver. It truncates the text at to size of the paper. If you use a wider paper size (like Ledger), you may be able to get more of the text.
------------------
Q. Is there any way to prevent QuickReport from doing a page eject (form feed) at the end of a page or print job?
A. As long as you use printing via the windows printer driver (TPrinter and TQRPrinter both use this) there is no way to avoid the page eject after the print job has finished. This behavior has been built by MS into the printer driver design, for a good reason. The system has to be able to deal with several apps running in parallel printing all to the same printer and it assumes that each job starts on a new page.
------------------
Q. How do I print to a file without changing the printer's setup, or getting a prompt for a file to print to?
A. This is the title of a FAQ from the Inprise Delphi Developer support page. This question is answered at http://www.inprise.com/devsupport/delphi/qanda/1599.html
------------------
Q. When you look in the queue for a print job, Quick Report print jobs have no name. How can I give a Quick Report printout it a name for the queue?
A. Did you set the ReportTitle property of the report? This gets passed to the TPrinter object when you print and that value will be used as the name of the print job.
------------------
Q. I have a PC with a HP692C deskjet printer as default and when I try to print QuickReport raise the error : Printer index is not valid. Only with this printer.
A. This message doesn't come from QuickReport, it comes from the Delphi printers unit. You can get this message if you try to specify a printer option that the printer driver does not accept. If you copy the printers unit (if you have the VCL source code) to your project directory and add it to the project, you put break points in it to see which setting is causing your problem.
------------------
Q. I get a printer error when I print a range of pages.
A. There is a known problem where a range of pages will cause an error when you have controls that cause a band to stretch. The length of a band that stretches is not known until the band is actually printed. If pages are skipped, the page count is off and report throws an error. This will be addressed in a future release.
------------------
Q. I am setting the control's font to Arial but it is printing as Courier (or vice versa).
A. Check the control's Font.Pitch property. If you select Arial and set the pitch to fpFixed, Windows will substitute the closest match that supports that pitch.
------------------
Q. I can't get the Bin Selection for quick reports to work. No matter what I try, everything goes to the same bin. How do you select output bins?
A. You should be setting the report's PrinterSettings.Outputbin property to the bin that you want to use. Only the bins listed on the manual page for the outputbin property (5-121) can be selected. Device specific bins are not supported at this time. If the printer's default bin is a device specific bin, you may have to set to another bin in order for QR2 to be able to select a bin.
------------------
Q. I am trying to layout my report to print using the Generic/Text Only driver, but I am having trouble getting the text to line up and blank lines get inserted into the printout.
A. This is what I do when I am designing a report for the Generic/Text only driver.
Set the report units to Characters.
Set the report font to 'Courier New' and the size to 10.
Set the height of the band to slightly less than the height of the text controls. The default height of the QRDBText control is 17 when I use these settings. I set the detailband height to 16. This should eliminate any extra blank lines from the output.
------------------
Q. I don't see the progress window during the print when I use:
myreport.quickrep1.Prepare;
myreport.quickrep1.QRPrinter.Print;
myreport.quickrep1.QRPrinter.Free;
myreport.quickrep1.QRPrinter := nil;
How do I enable the progress window using the above code?
A. The progress windows is not applicable to that method as the report is not being generated at print time. The report was rendered to a metafile with the prepare method and the print method is just copying the metafile to the printer.
------------------
Q. I'm getting a 'Printer is not currently printing' error when I try to print a report, I have not been able to find a reason for this, it only happens with certain reports. (Others print without problems)
A. Check the report.printersettings.FirstPage and the report.printersettings.LastPage properties. If they are set to values outside of the number of actual pages in the report, you will get this error at runtime.
------------------
Q. The printout doesn't match the preview exactly.
A. We use Windows API calls to get the font height and width information back and some fonts do not return the correct information.
------------------
Q. I have a report that prints fine on a HPIII printer but not on the HP4. Either the text is missing, or the bands print black.
A. There have been many reports of problems with the HP4 (and HP5) printers. You should make sure that you are using the current driver from HP's web site (http://www.hp.com/cposupport/jsnav/prhome.html). You may also need to check the page protect option in the printer driver and/or set the DPI to 300.
------------------
Q. The output from preview is correct, but printing from the preview does not print all of the data or the data has values from the last run of the report.
A. If the problem is only when you print from a preview, then you will need to reset your data (datasets and/or variables) in the BeforePrint event of the QuickReport. This event gets called whenever the report needs to be generated.
When the report is regenerated, sometimes you will have to reset your dataset. One example is if the dataset has a memo and you are connected to a SQL database server like Oracle. The problem seems to be in the BDE's BLOB caching.
Another situation would be if you are using OnNeedData and that event is controlled by a variable that needs to be initialized at the start of the report.
------------------
Q. How can I tell how the user exits the report's PrinterSetup method? It does not pass back the status.
A. You can test the value of report's tag property (with version 2.J or newer) after calling PrinterSetup and if it's 1, then they selected OK.
Many users have asked for the ability to print automatically if the user selects OK from PrinterSetup. You would code that like this:
with frmReport.quickrep1 do
begin
PrinterSetup;
if tag = 0 then
print;
end;
To do this in the preview will require using a custom preview and passing in a reference to the calling report to the preview. That will allow you to call PrinterSetup and be able to check the tag value. We have a sample preview that does this and it is available upon request.
------------------
Q. How can I check to see if the user cancelled the printing of a report?
A. You can use the AfterPrint of the report to set a flag as it will only get called if the report prints to completion.
A. (QR3) The report has a Cancelled property that gets set to True if the user cancels a report (preview only, not the printout).
------------------
Q. How do I determine the paper size of the printer at runtime?
A. If you use the following code before you call your report, you can specify the default size:
with TQRPrinter.Create do
begin
Printerindex := -1;
QuickRep1.Page.PaperSize := PaperSize;
Free;
end;
This assumes that you are using the default printer and your report is named QuickRep1.
------------------
Q. After calling QuickRep.PrinterSetup to pick a specific printer, what's the best way to get the name of the printer that was just chosen?
A. The printerindex is stored in the report's printersettings.printerindex property. The following example will set the form's caption to the current printer for the selected report:
with TfrmReport.Create(Application) do
begin
QuickRep1.PrinterSetup;
self.caption := printer.printers[QuickRep1.printersettings.printerindex];
QuickRep1.Preview;
Free;
end;
------------------
Q. I can not get the PrintBackground to work. In the preview sample I added a menu with the code:
procedure TMain.PrintBackground1Click(Sender: TObject);
var
aForm : TReport1Form;
begin
Application.CreateForm(TReport1Form, aForm);
aForm.QuickRep1.PrintBackground;
aForm.Free;
end;
When the PrintBackground method is called an exception is raised.
A. You are freeing the report while it is printing in the background. You can't free the report until it has finished printing. The following example creates a report, calls PrintBackground, and then waits until it has finished before freeing the report:
Application.CreateForm(TfrmGroupTest, frmGroupTest);
with frmGroupTest do
begin
QuickRep1.PrintBackground;
while QuickRep1.QRPrinter.Status <> mpBusy do
Application.HandleMessage;
while QuickRep1.Available = False do
Application.HandleMessage;
Free;
end;
------------------
Q. We have an application, that prints a form developed in QR 2.0i. During development we used a LEXMARK printer an everything worked fine. But our customer have another printer a Kyocera, on that printer the print doesn't work.
A. One thing to look at is how complicated your form is and how much memory is in each printer. QuickReport renders each page to the printer canvas supplied by the printer driver. If the printer resolution is set too high and it doesn't have enough ram to render the entire page, you will get garbled or missing output, depending on the printer and/or driver. One way to verify that this is the problem would be to lower the printer's resolution through it's driver and then try to print the report.
------------------
Q. I'm trying to write a report that gets printed to the windows generic text-only printer driver. Some lines move around when it is actually printed. Do you have any ideas?
A. Try setting the report's font to "Courier New" at size 10. Then set the height of the band to 16 and if that cleans up the output. To save paper while testing this, set the printer driver's destination to "FILE:"
------------------
 

Similar threads

A
回复
0
查看
943
Andreas Hausladen
A
A
回复
0
查看
992
Andreas Hausladen
A
A
回复
0
查看
413
Andreas Hausladen
A
A
回复
0
查看
619
Andreas Hausladen
A
A
回复
0
查看
819
Andreas Hausladen
A
后退
顶部