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

Closeing a Form containg a Report Object

edited July 2003 in General
Hello All,
Here is the problem. I have an MDI Application. I create a childForm
that contains my report object. I then Print the report to the screen.
When I close the print preview window I get the following events to fire.
First the AfterPrint event fires then the PreviewFormClose event fires. I
now need to release the Form. If I release the form in the PreviewFormClose
event I get an AV.
I never see the event ReportPrintingComplete fire. I would assume at this
point that this would be the better place to release the form containing the
report. Should this event fire? Also as has been asked before but no
answer given. If you are printing to the screen only, the print command
returns and if I release the form then the preview window closes immediately
without allowing a user to actually see the report. So the other question
is this. When should I release the form containing a report when the only
thing we are doing is printing to the screen?

Thank you anyone who can help.

Eric Brooksby

Comments

  • edited July 2003
    Hi Eric,

    It is possible to close a child form from the PreviewFormClose event only if
    you use a TTimer object to do so. This is to allow the report to finish its
    destroy sequence first before destroying the form. Below is a small example
    demonstrating how to do this. The report resides on an invisible child form
    and once the preview dialog is closed, a message will pop up saying when the
    form has been destroyed. Notice that the TTimer is set in the
    PreviewFormClose event.

    http://www.digital-metaphors.com/tips/CloseFromPreview.zip

    --
    Best Regards,

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