Auto close preview in RAP

Hi,

Is it possible in RAP after printing to an actual printer or file to automatically close the preview.

Thanks,

Ken

Comments

  • edited September 2019
    Hi Ken,

    In my quick testing, it appears to be possible with a RAP passthru function from the AfterPrint event after checking for the proper device. Something like the following...

    TmyClosePreviewFunction = class (TraSystemFunction)
    public
    procedure ExecuteFunction(aParams: TraParamList); override;
    class function IsFunction: Boolean; override;
    class function GetSignature: string; override;
    end;

    ...

    procedure TmyClosePreviewFunction.ExecuteFunction(aParams: TraParamList);
    var
    lReport: TppReport;
    begin

    GetParamValue(0, lReport);

    if (lReport.PreviewForm <> nil) then
    lReport.PreviewForm.Close;

    end;

    class function TmyClosePreviewFunction.GetSignature: string;
    begin
    Result := 'procedure ClosePreviewForm(aReport: TppReport);';

    end;

    class function TmyClosePreviewFunction.IsFunction: Boolean;
    begin
    Result := False;

    end;

    initialization
    raRegisterFunction('ClosePreviewForm', TmyClosePreviewFunction);

    finalization
    raUnRegisterFunction('ClosePreviewForm');
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thanks Niko. Will try this.
  • Sory, - Nico
Sign In or Register to comment.