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

Default viewer settings

edited October 2006 in General
RB 10.04, Delphi 7, dbExpress, ASA 9.02

Previously I have used a descentant of TppCustomPreviewer to force a
maximized view of the report rather than the normal version displayed by
default. Now adding text search and email features in the same way as the
demo's suggest, this descendant version of the viewer overwrites the icons
and therefore the features. I only used it to maximize the screen size.

Is there a better way to default the screen size to maximized, and can you
set default values such as text search option for ALL reports rather than
having to select the for each report?

Thanks,
Bill Skelton

Comments

  • edited October 2006
    Hi Bill,

    If you are loading templates, you can always assign the preview form
    settings after the template has been loaded in order to keep the setting
    consistant for every report. You would need to use a template event such as
    OnLoadEnd in order to do this successfully. Also, a very easy way to create
    a custom preview is to use the preview plugin archeticture which keeps all
    the normal functionality and allows you to simply change what you like.
    Below are a couple articles that may help.

    ----------------------------------------------
    Tech Tip: Using Template Events
    ----------------------------------------------

    The Report.Template object has several events that can be used for
    customizing what happens when a report is loaded or saved:

    - OnLoadStart
    - OnLoadEnd
    - OnNew
    - OnSaveStart
    - OnSaveEnd


    The OnLoadEnd and OnNew events are often used to perform actions related to
    report and data initialization.

    The OnSaveEnd event is often used to save additional descriptive ("meta")
    data to the database each time the report is saved.

    Example:

    The Report.Template events are public and therefore must be assigned at
    run-time.


    1. In the private section of your form declaration you can declare an
    event-handler method:

    TForm = class(TForm)
    private
    procedure myTemplateOnLoadEndEvent(Sender: TObject);

    public

    end;


    2. In the Form.OnCreate event, you can assign the event-handler to the
    event:

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;

    end;


    3. Implement the event-handler method:

    procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
    begin

    {add code here to initialize the report or data, etc. }
    ppReport1.PrinterSetup.MarginTop := 0.5;

    end;

    -----------------------------------------
    Article: Creating a Preview Plugin
    -----------------------------------------

    Q: I've followed the tutorials and registered a Preview Form replacement but
    that did not affect the TppDesigner's Preview workspace.


    A: Do not use the form replacement, but rather, there is a different
    architecture built into the preview form that is registered by default.



    You will need to register a TppPreview descendent. The class you register
    is used to create the preview controls inside the standard print preview
    form and the designer preview workspace.


    Here is an example of creating a simple custom preview that access the
    viewer its been assigned in order to change the page color. You can also do
    more advanced operations such as adding and removing buttons and change the
    behavior of the preview form. Access the inherited controls via. protected
    properties and override the virtual methods in order to customize behavior.

    Open ppPreview.pas and view the TppPreview class as a guide to create a
    custom preview descendent.


    unit MyPreviewPlugin;

    interface

    uses
    ppPreview;

    type
    TMyPreviewPlugin = class(TppPreview)
    public
    procedure BeforePreview; override;

    end;


    implementation

    uses
    Graphics;


    procedure TMyPreviewPlugin.BeforePreview;
    begin
    inherited BeforePreview;

    Viewer.PageColor := clRed;

    end;

    initialization
    TppPreviewPlugIn.Register(TMyPreviewPlugin);

    finalization
    TppPreviewPlugIn.UnRegister(TMyPreviewPlugin);

    end.

    --
    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.