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

No Report.AfterPrint event!!

edited June 2008 in End User
Hi,

I have made an application which exposes the report-designer to the
end-user. I have a BeforePrint-handler in which I add a PageStyle to the
report to embed a watermark. In the AfterPrint-handler this
watermark-pagestyle is removed (I don't want it saved with the report).
When I choose 'Preview' in the designer the report shows fine. But, when
I switch back to the design-tab there is no AfterPrint-event!!

Is this a bug? How can I get an AfterPrint-event?

Any ideas,

TIA,

Ronald

Comments

  • edited June 2008
    Hi Ronald,

    Which version of ReportBuilder are you using? In my quick testing with RB
    10.09 and Delphi 2007, the AfterPrint event fired successfully just as I
    tabbed back to the designer from the preview window.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2008
    Nico Cizik (Digital Metaphors) wrote:
    I'm using RB 10.07!
    When I have time tonight I'll download and try 10.09.
    I'll let you know.
  • edited July 2008
    Ronald wrote:

    No success!

    I installed a clean version of Delphi 2007 (with last updates) and
    version 10.09 Enterprise of RB (on WinXP in a virtual PC). Much like my
    own development-machine.
    Then I went to ..\Demos\3. EndUser\1. ReportExplorer and edited
    MyEURpt.pas. I added the eventhandlers BeforePrint and AfterPrint for
    ppReport1. Both eventhandlers implement only a ShowMessage.
    After that I ran the demo and chose to edit the 'Customer List' in the
    folder Customers. Now, when I preview the report in the designer I get
    .... nothing!!!

    Maybe you could try this also and let me know what happens.

    Best regards,

    Ronald
  • edited July 2008
    Hi Ronald,

    If you are implementing event handlers in Delphi, then loading templates,
    you will most likely loose the event handlers due to the fact that the
    template saves all this information down. The easiest workaround is to
    implement all event handlers in RAP.

    --------------------------------------------
    Article: Troubleshooting Lost Event Handlers
    --------------------------------------------

    Let's assume you have created a report in Delphi and assign an event
    handlers to the OnPreviewFormCreate event of the report. The event is
    generated by Delphi as:

    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);

    You then save the report to an RTM file 'Report1.RTM.' The events are
    stored as references only, and so the RTM contains:

    object ppReport1: TppReport
    .
    .
    OnPreviewFormCreate = ppReport1PreviewFormCreate
    end

    You then go on to work on a different report. Saving it with under then
    name 'Report2.RTM'. Only this time, before you save the report you change
    the report component name to: rptOrders. Delphi automatically updates the
    event declaration for OnPreviewFormCreate event to:

    procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);


    You then create two buttons on the form, one to load Report1 and preview,
    the other to load Report2 and preview. When you run the app and click
    Report1, you an error. This is because the Report1.RTM file contains a
    reference to ppReport1PreviewFormCreate, a method which no longer exists (at
    least with this name) in the form.

    One answer is to load all your rtm files into the report component you will
    be using for loading. Fix any errors, reassign any events that get cleared.
    This will update your rtms to contain the proper event handler names.


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2008
    Nico Cizik (Digital Metaphors) wrote:
    I don't save the eventhandlers to the RTM. In
    Report.Template.OnSaveStart I make sure every event is cleared. Then in
    the OnSaveEnd I restore the handlers.
    The strange thing is, when you try the enduser-demo and you choose Print
    from the Preview-tab all events fire as they should! So, I don't think
    they were lost during load. Also, when you look at the rtm (of the
    'Customer List' in the demo-database you will see there are no
    BeforePrint and AfterPrint-events defined. For I know, when a property
    is not mentioned in the rtm the property doesn't get set. It keeps it's
    value from before the load.
    I'm curious, when you said 'the AfterPrint-event fired succesfully after
    tabbing from preview to design' did you mean the RAP-event or the
    report-event?
  • edited July 2008
    Hi Ronald,

    Yes I was testing in RAP and assumed the Delphi events would behave the same
    however this is a special case. Sorry about that.

    In this case the RAP and Delphi events will behave differently. In Delphi,
    the AfterPrint event is not designed to fire after you tab back from the
    preview for in the end-user designer. If you need an event to fire every
    time you change from the preview tab back to one of the designer tabs, I
    would suggest using the TppDesigner.OnTabChange event. You can use the
    NewTab parameter to keep track of which tab your user is currently using.

    --
    Regards,

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

    Best Regards,

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