Hide Print Button on Print Preview

Question

“How can I hide the Print button of the Report Preview?”

Solution

Here are two options:

1. Implement Report.OnPreviewFormCreate event:

uses
  ppPrvDlg;

procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
begin
  TppPrintPreview(ppReport1.PreviewForm).PrintButton.Visible := False;
end;


2. Implement a custom TppPreviewPlugin:

This solution is best for the case in which you need to hide the Print button for all (or many) reports:

unit MyPreviewPlugin;

interface
 
uses
  Classes,

  ppTypes,
  ppPreview;

type

TMyPreviewPlugin = class(TppPreview)
private

protected

public
  constructor Create(aOwner: TComponent); override;

end;

implementation

{ TMyPreviewPlugin }

constructor TMyPreviewPlugin.Create(aOwner: TComponent);
begin
  inherited;

  PrintButton.Visible := False;

end;

initialization
  TppPreviewPlugIn.Register(TMyPreviewPlugin);

finalization
  TppPreviewPlugIn.UnRegister(TMyPreviewPlugin);

end;