Home General

Remove Print button from Preview?

edited January 2018 in General
Hi Team,
Win 10, D10.2.2, latest RBEnt.
I want to allow the end user to see the report on the screen only and not be able to physically print or do anything
else with it.
Can I, if so Where/how, disable, preferably remove, the print button on the Preview screen?

Regards & TIA,
Ian

Comments

  • edited January 2018
    Ian Branch wrote:



    You can use the OnShow Event of Previewform
    to setup your OnShow Handler, where you can access those buttons:

    ppReport.OnPreviewFormCreate ==
    var
    vForm:TppCustomPreviewer;
    begin
    vform:=tppreport(sender).Previewform;
    vForm.OnShow:=my_previewformonshow;
    end;

    and later
    procedure previewformonshow(Sender: TObject);
    var
    vForm:TppPrintPreview;
    begin
    vform:=TppPrintPreview(sender);

    if vform<>nil then begin
    // now access buttons etc.
    vForm.BringToFront;
    end;
    end;


    Rgds, Yusuf


    --
  • edited January 2018
    Tks Yusuf,
    Not sure I know how exactly to do that.
    I am playing with ppViewer att to see what I can or cannot do with that.

    Regards,
    Ian
  • edited January 2018
    Additional info..

    I should have indicated, I am using the end-user core to retrieve the report into ppReport from the rbxxxx files.

    Ian
  • edited January 2018
    On 09/01/2018 08:02, Ian Branch wrote:

    So given that you have a TppReport instance that you are presumably
    using to call Print or PrintToDevices, why are you not able to make use
    of Yusuf's code example?

    Paul
  • edited January 2018
    Hi Ian,

    The Preview Dialog contains numerous helper properties which allow minor
    control over the report previewer. You can use the Report.PreviewForm
    property to access this (as Yusuf mentioned).

    http://www.digital-metaphors.com/rbWiki/Output/Preview/Hide_Print_Button_on_Print_Preview

    Another option is to create a custom preview plugin.

    http://www.digital-metaphors.com/rbWiki/Plugins/Dialogs/Preview_Plugin

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2018
    Hi Nico,
    Trying he first option as it seems the simplest.

    From my parent form I call the report with the following..

    {code}
    procedure TJobTicketsForm.RepairReportPrintClick(Sender: TObject);
    begin
    //
    if InStr(mscCoyJTPrint, dmC.JobTickets.FieldByName('JobStatus').AsString, ';') then
    begin
    sJobNo := alltrim(dmC.JobTickets.FieldByName('Job #').AsString);
    //
    with ReportsFrm.ReportsForm do
    begin
    ppRE1.LoadReport('Customer Repair Report', 2);
    ppR1.ShowAutoSearchDialog := False;
    ppR1.AutoSearchFields[0].SearchExpression := sJobNo;
    ppR1.Print;
    end;
    //
    end
    else MessageDlg(sPrintMsg, mtError, [mbOK], 0);
    //
    end;
    {code}

    ppRE1 & ppR1 are on the core module of the end-user example module, 'ReportsForm'.


    I have added 'ppPrvDlg' in the uses of ReportsForm and the following code..
    {code}
    procedure TReportsForm.ppR1PreviewFormCreate(Sender: TObject);
    begin
    TppPrintPreview(ppR1.PreviewForm).PrintButton.Visible := False;
    end;
    {code}

    I still get the print button on the Preview screen.
    Clearly I still have something wrong. :-(

    Regards,
    Ian
  • edited January 2018
    Since you are loading templates, the reference to the PreviewFormCreate
    event is likely being lost.

    Try re-assigning the event reference after the template is loaded.

    http://www.digital-metaphors.com/rbWiki/Design/Templates/How_To...Reassign_Event_Handlers

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2018
    Ah Ha! All good now.
    Tks Nico.

    Regards,
    Ian
This discussion has been closed.