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

Cancel print

edited December 2003 in General
Hi,

I use RB7 trial with Delphi 6 on Win2K pro.

I need to print several report . For each report, I call ppReport1.print
For the first report I show the printerdialog to get config and printer to
use.

if DocEnCours > 1 then
ShowPrintDialog := False
else
ShowPrintDialog := True;

My problem is if the user cancel print on the first call. How can I detect
the cancel when RBuilder "ask" the config printer at first time ??


Thanks,

Jean-Luc !

Comments

  • edited December 2003
    Hi,

    These articles should help you get on the right track.

    ------------------------------------------
    Tech Tip: Detecting whether PrintDialog's
    Cancel button was Selected
    ------------------------------------------

    When the print dialog is displayed to the
    user, you can determine whether the Cancel
    button was selected by using the
    Report.OnPrintDialogClose event.

    Example:

    procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
    begin

    if ppReport1.PrintDialog.ModalResult = mrCancel then
    ShowMessage('Use chose to cancel the print request');

    end;


    ------------------------------------------
    Tech Tip: Detecting whether Report was
    Printed to the Printer
    ------------------------------------------

    The Report.AfterPrint event can be used to
    determine whether the report was printed
    to the printer (rather than preview, ...).


    Example:


    procedure TForm1.ppReport1AfterPrint(Sender: TObject);
    begin

    if (ppReport1.PrinterDevice <> nil) then
    ShowMessage('Report was printed to the printer');

    end;



    Note: If the user cancels the report while it
    is running, then the Report.OnCancel event will
    fire, followed by the Report.AfterPrint event.

    Example:

    procedure TForm1.ppReport1Cancel(Sender: TObject);
    begin
    ShowMessage('Printing cancelled by user');

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.