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

Cancelling preview yields access violation

edited November 2009 in General
I'v got a user defined preview screen, with a pppreview component on it.
When the form is closed by the user, i call ppViewer.Cancel in the DoClose
procedure of the form.
SHortly after that the report object is freeAndNil'ed by the destroy method
of the datamodule that own the report.

After this an Access violation is raised in the TppEngine.RequestPage method,
probably because i'v destroyed the report-object too soon.

Is there a report or engine status i have to wait for, before freeing a report
object?

thanks

Comments

  • edited November 2009

    Try checking the Report.Printing boolean property. If that is true, then the
    report is still busy. Cancel does not immediatedly cancel the report, it
    sets a flag that is checked by the report engine and then the report engine
    shuts down gracefully.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2009
    Hello Nard,

    is the engine running in its own thread? and if not ... how can i make it
    continue after it has been interupted by the FormCLose event?
  • edited November 2009

    What are you trying to accomplish?

    In Windows a modal form executes in a different message loop than the rest
    of the program - this makes it seem like it is in a different thread. It is
    asynchronous. If an exception occurs it is handled differently. That is true
    for all Delphi modal forms.

    You can use ReportBuilder to print in a separate thread. See the RBuilder
    help topic for Report.BackgroundPrintSettings.

    If you Cancel report, it cannot be continued. You can call Report.Reset and
    then call Report.Print or PrintToDevices to start generation from the
    beginning.

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

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