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

printbutton on previewform

edited June 2008 in General
Hello

one of my customers wan't to prevent some users of printing, they can run
only a preview.
But how can i disable or hide the printbutton in the preview form

Met vriendelijke groet, With kind regards,


Frank Beerens

Comments

  • edited June 2008
    Hi,
    please use lPreviewForm.PrintButton.Visible or
    lPreviewForm.PrintButton.Enable:

    procedure TMainForm.ppReport1PreviewFormCreate(Sender: TObject);
    var lPreviewForm: TppPrintPreview;
    print_status1:String;
    begin
    //uses ppPrvDlg;
    lPreviewForm := TppPrintPreview(ppReport1.PreviewForm);
    lPreviewForm.PrintButton.Visible:=(MainForm.ADOTable1.FieldByName
    ('number_of_print').AsInteger <= 0);
    end;

    Regards,

    Ali Abbasi


    run



    --- posted by geoForum on http://delphi.newswhat.com
  • edited June 2008
    Hello ?'m using rb 7.04 but there is no Printbutton property ?
    Can i do it on another way ?





  • edited June 2008
    Hi Frank,

    In your case you will need to create a custom preview dialog. I strongly
    recommend that you consider upgrading your version of ReportBuilder (and
    Delphi if needed) so you can benefit from the latest features.

    -----------------------------------------
    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
  • edited June 2008
    Dear Frank,

    My easy method work with versions over RB 9,So please upgrade your RB.
    Regards,

    Ali Abbasi

    strongly
    (and
    replacement but
    register
    preview
    also do
    the
    protected
    behavior.
  • edited July 2008
    If i create a custom preview how can i acces the print button ?

  • edited July 2008
    Hi Frank,

    A custom preview plugin will descend from the TppPreview class giving you
    access to all its protected properties and routines allowing you full
    control over the form.

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