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

How do I trap for the report's print dialog cancel button being clicked?

edited September 2005 in Devices
Scenario:

User selects a report to print.
Report's Print dialog form displays.
User decides to click on the cancel button which closes the report's print
dialog form.

I have several lines of code that will need to execute if a user does decide
to print the report (this is a report that is printed to a file and then the
file is sent to a dot matrix printer so that it can print faster without
being in graphics mode).

The code referenced above does NOT need to be executed if user decides to
click on the cancel button of the report's print dialog form.

Your suggestions will be greatly appreciated.

Thanks
Karen

Comments

  • edited September 2005
    ------------------------------------------
    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;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2005
    Thanks!

  • edited October 2005
    My Reports PrintDialog is nill , how do I assign printdialog to the report?

    I'm I missing something here.

    Thanks
    -Bhoj

  • edited October 2005

    Report.PrintDialog is created and free'd internally when you print a report.
    You can use the OnPrintDialogCreate and OnPrintDialogClose events to access
    the print dialog.



    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2005
    Thanks Nard,

    That what I was trying to do but the Report.PrintDialog is nil where do I
    assign the printer dialog?
    Do I have to create my own printerdilog and assign it at on
    PrintDialogCreate event ?

    Thanks



  • edited October 2005

    If Report.ShowPrintDialog is set to True, then the PrintDialog will be
    created internally. The OnPrintDialogCreate event will fire just after the
    PrintDialog is created. The Report.PrintDialog property will be non nil in
    this event and in the OnPrintDialogClose event.

    If you want to see how this works, I recommend adding RBuilder\Source to the
    Delphi library path and then tracing the source code (see ppProd.pas and
    ppReport.pas).





    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.