Close-Button in Panel (TppPreviewPlugIn)

Hello,

I use the TppPreviewPlugIn to display the preview in a TPanel. Unfortunately, a close button is displayed in the toolbar. How can I configure this button so that it is only displayed for canceling while printing, but is otherwise hidden? I don't need its function to close because it interferes with the program flow.

Thank you and happy weekend!

Comments

  • Hi Utzel,

    First take a look at the TppPreview.PrintStateChangeEvent for how the cancel button is manipulated in the standard Preview. You will need to override, copy, and alter this code to hide the button rather than change the caption when the viewer is no busy.

    Next take a look at the TppPreview.ToolButtonClickEvent and TppCustomPreview.PerformPreviewAction for what happens when the button is clicked. Hiding the button after the viewer is done should make altering these unnecessary but it is good to know how it functions.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

  • I overwritten and registered the class locally and it works perfectly.
    implementation
    
    uses
      ppPreview;
    
    {$R *.dfm}
    
    type
      TmyPreviewPlugIn = class(TppPreview)
      protected
        procedure PrintStateChangeEvent(Sender: TObject); override;
      end;
    
    procedure TmyPreviewPlugIn.PrintStateChangeEvent(Sender: TObject);
    begin
      inherited;
    
      CancelButton.Visible := Viewer.Busy or Viewer.DesignViewer;
    end;
    
    constructor TForm1.Create(AOwner: TComponent);
    begin
      inherited;
    
      TppPreviewPlugIn.Register(TmyPreviewPlugIn);
      FPreview := TppPreviewPlugIn.CreatePreviewPlugin(Panel1);
    end;
    
    destructor TForm1.Destroy;
    begin
      TppPreviewPlugIn.UnRegister(TmyPreviewPlugIn);
    
      inherited;
    end;

    Thank you so much!
Sign In or Register to comment.