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

Print Button Click

edited June 2002 in General
Hallo..
I need to write code in the click event of the print button
on the previewform..
how can I do?


-----------------------------------
Raffaele Gabrielli
ENTER s.r.l.
supptec@entersrl.it

Comments

  • edited June 2002
    Hi Raffaele,

    what do you want to achieve?

    regards,
    Chris Ueberall;

  • edited June 2002
    I need to view the preview of the Report
    but when i decide to print the report
    i want to kill the print job and send a direct protocol to my
    Label Printer because if i print by windows driver
    my Label Printer prints one label every 8 seconds.


    -----------------------------------
    Raffaele Gabrielli
    ENTER s.r.l.
    supptec@entersrl.it




    "Chris Ueberall [TeamDM]" ha scritto nel messaggio
  • edited June 2002
    Raffaele,

    I used the event 'TppReport.OnPreviewFormCreate' with the following code.

    var
    button : TSpeedButton;
    begin
    button :=
    TSpeedButton(TppReport(Sender).PreviewForm.FindComponent('spbPreviewPrint'))
    ;
    if button <> nil then begin
    button.OnClick := MyPrintButtonClick;
    end;

    HTH,
    Chris Ueberall;

  • edited June 2002
    On Thu, 27 Jun 2002 13:43:45 +0200, "Raf" wrote:

    There is a demo that shows how to disable the print button.

    http://www.digital-metaphors.com/tips/myCloseButtonPreviewPlugin.zipYou

    After downloading, you will need to fix the project file to get rid of
    an invalid path name. The module is MyCloseButtonPreviewPlugIn. Just
    change the BeforePreview to the following code and add YourRoutineName
    to get your printing done. To remove the print button from the screen
    just set lPrintButton.Visible := False;

    procedure TmyPreviewPlugIn.BeforePreview;
    var
    lPrintButton: TSpeedButton;
    begin
    inherited BeforePreview;
    lPrintButton := GetButtonForPreviewAction(paPrint);
    if (lPrintButton = nil) then
    raise Exception.Create('Unable to find print button.');
    // lPrintButton.Visible := False;
    lPrintButton.OnClick := YourRoutineName;
    end;

    Hope this helps.

    Sidney
  • edited June 2002
    Tanks..

    Chis.. your solution don't make the trick!

    TSpeedButton(TppReport(Sender).PreviewForm.FindComponent('spbPreviewPrint'))

    return nil.

    -----------------------------------
    Raffaele Gabrielli
    ENTER s.r.l.
    supptec@entersrl.it


  • edited June 2002
    Raffaelle,

    sorry, but you are right, the given code works until 6.0.
    Sidney pointed you to a demo for downloading, delete the trailing 'You'.
    There is also the following available :
    http://www.digital-metaphors.com/tips/PreviewPlugin.zip

    HTH,
    Chris Ueberall;

  • edited June 2002
    Raffaele,

    another solution would be ...


    ------------------------------------------------------------
    Tech Tip: Replacing Built-in Dialogs/Forms in ReportBuilder
    -----------------------------------------------------------

    ReportBuilder has an open architecture for replacing any of the built-in
    dialogs. You can replace any of the built-in dialogs by creating a new
    form that inherits from an abstract ancestor and then registering it as
    the new built-in dialog.

    For example to replace ReportBuilder's preview dialog you could

    1. Create a new Preview dialog by renaming ReportBuilder's default
    preview dialog, then doing a SaveAs to save it under another unit name.

    The default dialog resides in RBuilder\Source\ppPrvDlg.pas and the form
    is called ppPreviewDialog. You should assign your form a unique name,
    for example, myPreviewDlg, and save the unit to another name. Also save
    the unit to the directory where your other forms are stored (not
    RBuilder\Source).

    2. Make desired changes.

    You will notice that the preview dialog inherits from an ancestor
    TppCustomPreviewDialog - this ancestor resides in ppForms.pas (where all
    the abstract ancestor forms for ReportBuilder are defined).

    3. Register the new form.

    Declare an initializtion section at the bottom of the unit:

    initialization

    ppRegisterForm(TppCustomPreviewer, TmyPreviewDlg);


    4. Add the new unit to your project and compile.

    Now your preview dialog should be automatically created and destroyed by
    ReportBuilder. The two page preview dialog in the
    RBuilder\Demos\Reports\Demo.dpro was created this same way. The only
    difference is the ppRegisterForm call is in then OnClick event of the
    button.


    regards,
    Chris Ueberall;
This discussion has been closed.