Home Devices
New Blog Posts: Merging Reports - Part 1 and Part 2

TppCustomPrintDialog owner dialog

edited March 2003 in Devices
Hi!!

I have to implement folowing:
I can ask a preview of a report and press the print button, but as long as
the ok button is not pressed there's no need to do something except for
showing the report.
When the user pressed ok, a report has to be generated and stored in a
database containing printed invoices.
Now, the problem is that the before printing method getscalled before the
users selects a printer and presses ok on the PrintDialog.

I'v made my own TDBMSInvoicePreview = class(TppPreview) with an overrided
Print method.
implemented af folowing

procedure TDBMSInvoicePreview.Print;
function CreatePrintDialog: TppCustomPrintDialog;
var
lFormClass: TFormClass;
lPrintDialog: TppCustomPrintDialog;
begin
Result := nil;
lFormClass := ppGetFormClass(TppCustomPrintDialog);
lPrintDialog :=
TppCustomPrintDialog(lFormClass.Create(Application));

lPrintDialog.Report := Report;
lPrintDialog.DeviceType := report.DeviceType;
lPrintDialog.Printer := Viewer.report.Printer;
lPrintDialog.LanguageIndex := report.LanguageIndex;
lPrintDialog.AllowPrintToArchive := report.AllowPrintToArchive;
lPrintDialog.AllowPrintToFile := report.AllowPrintToFile;
lPrintDialog.ArchiveFileName := report.ArchiveFileName;
lPrintDialog.TextFileName := report.TextFileName;

TppPageRequest(lPrintDialog).PageRequested := report.CurrentPage;

if not(report.Icon.Empty) then lPrintDialog.Icon := report.Icon;
lPrintDialog.Init;
Result := lPrintDialog;
end;

var
aPrintDialog : TppCustomPrintDialog;
begin
try
{Hide the original printdialog and use mine}
Report.ShowPrintDialog := false;
aPrintDialog := CreatePrintDialog;
if aPrintDialog.ShowModal = mrok then begin
Report.Printer.PrinterName := aPrintDialog.; <<<<<PROBLEM see
below
inherited;
end;
finally
FreeAndNil(aPrintDialog);
end;
end;

PROMBLEM:
How do i assign the data of the selected printer/settings to the report?
Or does anybody have another solution?

Any assistance or guidance would be much appreciated.

Thx,
Vincent

Comments

  • edited March 2003
    Typecast the Printer property of the print dialog as a TppPrinter object.
    Then you can access the configured printer object. Look in ppProd.pas for an
    example of how we use the print dialog after the dialog has been shown.
    Start in the TppProducer.PrintToPrinter method.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Thx, ill try it imm.
    Will post the source once i found the solution

    greets, Vinny

This discussion has been closed.