DeviceType question
If the deviceType is set to screen the preview is shown first and then you
can print. If the deviceType is set to printer you can print but there is no
way of previewing.
Is there a setting that allows the print dialog to show the preview just
like previewing shows the print dialog?
can print. If the deviceType is set to printer you can print but there is no
way of previewing.
Is there a setting that allows the print dialog to show the preview just
like previewing shows the print dialog?
This discussion has been closed.
Comments
Sorry, this is not possible with the current ReportBuilder print dialog. It
is possible to replace any dialog (except the designer) in ReportBuilder
with your own custom dialog however. This may be something you want to
pursue if you need to be able to preview from the print dialog.
------------------------------------------------------------
Tech Tip: Replacing Built-in Dialogs/Forms in ReportBuilder
------------------------------------------------------------
ReportBuilder has an open architecture for replacing any of the built-in
dialogs. You can replace any of the built-in dialogs by creating a new form
that inherits from an abstract ancestor and then registering it as the new
built-in dialog.
For example to replace ReportBuilder's print dialog you could
1. Create a new Print dialog by renaming ReportBuilder's default print
dialog, then doing a SaveAs to save it under another unit name.
The default dialog resides in RBuilder\Source\ppPDlg.pas and the form is
called ppPrintDialog. You should assign your form a unique name, for
example, myPrintDlg, and save the unit to another name. Also save the unit
to the directory where your other forms are stored (not RBuilder\Source).
2. Make desired changes.
You will notice that the print dialog inherits from an ancestor
TppCustomPrintDialog - this ancestor resides in ppForms.pas (where all the
abstract ancestor forms for ReportBuilder are defined).
3. Register the new form.
Declare an initializtion section at the bottom of the unit:
initialization
ppRegisterForm(TppCustomPrintDialog, TMyPrintDialog);
4. Add the new unit to your project and compile.
Now your preview dialog should be automatically created and destroyed by
ReportBuilder. The two page preview dialog in the
RBuilder\Demos\Reports\Demo.dpro was created this same way. The only
difference is the ppRegisterForm call is in then OnClick event of the
button.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I think we've almost got it, thanks. I've added a "Preview" button to our
custom print dialog, but I can't find a suitable object in TppPrintDialog or
TppCustomPrintDialog allowing me to get back to the TppReport. Here's the
code (notice block commented out):
unit UPrintPreviewDlg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ppPDlg, ImgList, StdCtrls, ExtCtrls, Buttons;
type
TppPrintPreviewDialog = class(TppPrintDialog)
btnPreview: TButton;
procedure btnPreviewClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ppPrintPreviewDialog: TppPrintPreviewDialog;
implementation
uses
ppForms, ppDevice;
{$R *.dfm}
procedure TppPrintPreviewDialog.btnPreviewClick(Sender: TObject);
begin
{
myReport.DeviceType := dtScreen;
myReport.Print;
}
end;
initialization
ppRegisterForm(TppCustomPrintDialog, TppPrintPreviewDialog);
end.
To create custom dialogs, etc I recommend that you consult the source code
installed to RBuilder\Source.
The PrintDialog.Report property provides access to the report. This property
is declared in the ancestor TppForm class (ppForms.pas). The property type
is TComponent so you have to typecast it.
I do not know whether calling Report.Print a second time will work. (I
assume you already called it once to show the PrintDialog). Have never tried
it.
--
Nard Moseley
Digital Metaphors Corporation
http://www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
procedure TppPrintPreviewDialog.btnPreviewClick(Sender: TObject);
var
rep:TppReport;
begin
rep:=TppReport(Report);
rep.DeviceType:=dtScreen;
rep.Print;
end;
Thanks very much Nard and Nico!