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

Form needs to be visible to print

edited May 2010 in General
We have an application that runs its report from a DLL. The DLL does not
show its form that the ppReport component is on, and this does not cause a
problem when previewing the report.

However, if the user prints the report without previewing (DeviceType :=
dtPrinter) then we get an Access Violation after the print dialog is
displayed, or the application crashes out completely.

After some playing around, I set the form's Visible property to True after
the DeviceType is set, and before the Print; method is called. This now
prevents the AV from occuring.

Is there a reason why this should be? I'm happy that it now works but I
spent a lot of time trying to get there.

Jason.
--
Jason Sweby
Software Development Manager,
Carval Computing Limited, Plymouth, UK

Payroll - HR - T&A - Access Control

Comments

  • edited May 2010

    I bet I have never suggested this before, but it would be great if when
    posting support questions, developers would include environment info:
    Windows version, Delphi version, ReportBuilder version and edition, Data
    Access components, database engine, printer, etc. :)

    Yesterday I received an example from a DLL example from a customer that can
    preview or print directly. The report is on a form that does not get shown.
    Printing directly does not result in an not AV. However, the calling form
    does not get re-activated unless I added a call to BringToFont following the
    call to the DLL, like this...

    Call DLL here
    Self.BringToFront;

    The other solution I found was to call Application.CreateHandle inside the
    DLL, prior to creating the form.

    For my testing I used D2007, RB 11.08. The example used the DBDemos data.



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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2010
    Nard,

    Just my luck you should pick me up on that, this must be the first message
    I've ever posted that didn't include that information!

    Delphi 6, RB Enterprise 11.08 (+ Windows XP & daODBCExpress).

    Thanks for the reply.
    Jason.

This discussion has been closed.