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

Printer Button

edited August 2002 in General
Hi


Can I disable (or delete) the printer button in a report preview ?


The user do not print any reports in my application, only view.


Thanks


Gerson Luiz Pedrinho
APP Sistemas

Comments

  • edited August 2002
    This question has been answered today in the component-writing newsgroup.
    Source code is provided in that thread to a unit which you can add to your
    project to replace the previewer's behavior in order to suppress the print
    button.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    Dears,

    That is possible executing one "looping" for all the existing components in
    the "PreviewForm".
    However as it does not have "Caption" and nor name in the objects, the only
    form that I found to identify the "PrintButton" was through its "Hint".

    Example:

    { evento onPreviewFormCreate }
    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
    var
    i, j: integer;
    begin
    for i := 0 to ppReport1.PreviewForm.ComponentCount-1 do
    for j := 0 to ppReport1.PreviewForm.Components[i].ComponentCount-1 do
    if ppReport1.PreviewForm.Components[i].Components[j] is TSpeedButton
    then
    if
    (UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H
    int) = 'IMPRIMIR') or

    (UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H
    int) = 'PRINT') then

    TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).Enabled :=
    False;
    end;

    []s,
    Alessandro Ferreira
    Support Technician The Club, www.theclub.com.br.


  • edited August 2002
    You can try this:

    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
    var
    ButtPrint : TSpeedButton;
    II, JJ, ZZ : Integer;
    LComp, LComp2 : TComponent;
    begin
    ButtPrint := nil;

    with (Sender as TppReport) do
    begin
    with (PreviewForm as TppPrintPreview) do
    begin
    for II := 0 to ComponentCount-1 do
    if Components[II] is TPanel{=TppPreview.ToolBar} then
    begin
    for JJ := 0 to Components[II].ComponentCount-1 do
    begin
    LComp2 := Components[II].Components[JJ];
    if LComp2 is TSpeedButton then
    begin
    if TSpeedButton(LComp2).Tag = Ord(paPrint) then
    begin
    ButtPrint := TSpeedButton(LComp2);
    Break;
    end;
    end;
    if Assigned(ButtPrint) then Break;
    end;
    end;
    end;
    end;

    if Assigned(ButtPrint) then
    begin
    ....
    end;
    end;

    Regards
    Roman Krupicka
This discussion has been closed.