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

Cannot make mail button appear in D-2006 and RB 10.03

edited July 2006 in General
Below works for D-7 but does not work in D-2006. I can seem to make the
Mail icon appear. The Expand all button still works.

Please advise.
Larry

unit MyPreviewPlugin;

interface

uses
Controls, ExtCtrls,
Buttons,
ppClass, ppReport,
ppPreview, ppTypes;

type

{@TMyPreviewPlugin}
// inherit standard Report Previewer.
TMyPreviewPlugin = class(TppPreview)
private
FCustomButton: TSpeedButton;

procedure CustomButtonClickEvent(Sender: TObject);
procedure ShiftControls;

protected
procedure PageChangeEvent(Sender: TObject); override;

public
procedure CreateToolbarItems; override;
procedure BeforePreview; override;

end;

implementation

uses
Forms,
ppPreviewIcons, ppForms;

procedure TMyPreviewPlugin.BeforePreview;
begin

inherited BeforePreview;
Report.EmailSettings.Enabled := True;
EmailButton.Visible := Report.EmailSettings.Enabled; //True;
ShiftControls;

end;

procedure TMyPreviewPlugin.PageChangeEvent(Sender: TObject);
begin

inherited PageChangeEvent(Sender);

ShiftControls;

end;

procedure TMyPreviewPlugin.CreateToolbarItems;
begin

inherited CreateToolbarItems;

ToolBar.ShowHint := True;


// Create a speed button in code
FCustomButton := TSpeedButton.Create(Toolbar);
FCustomButton.Parent := ToolBar;
FCustomButton.Flat := True;
FCustomButton.Left := 16;
FCustomButton.Top := 2;
FCustomButton.ParentShowHint := True;
FCustomButton.Hint := 'ExpandAll';
// steal an icon from Report Builder
FCustomButton.Glyph.Handle :=
TppPreviewIcon.CreateIcon(TppAutoSearchIcon);
FCustomButton.OnClick := CustomButtonClickEvent;
FCustomButton.GroupIndex := 99;
FCustomButton.AllowAllUp := True;

end;

procedure TMyPreviewPlugin.CustomButtonClickEvent(Sender: TObject);
begin
// Add procedure calls to expand and collapse the previewed report.
if (FCustomButton.Down) then
begin
TppReport(Report).ExpandDrillDowns;
FCustomButton.Hint := 'Collapse All';
end
else
begin
TppReport(Report).CollapseDrillDowns;
FCustomButton.Hint := 'Expand All';
end;


Viewer.RegenerateReport;

end;

procedure TMyPreviewPlugin.ShiftControls;
begin
// just to keep buttons in place
Toolbar.Left := FCustomButton.Left + FCustomButton.Width + 7;
// StandardToolbar.Left := FCustomButton.Left + FCustomButton.Width + 7;
end;


// Register class so it is the default previewer.
initialization
TppPreviewPlugIn.Register(TMyPreviewPlugin);

finalization
TppPreviewPlugIn.UnRegister(TMyPreviewPlugin);


end.

Comments

  • edited July 2006
    Hi Larry,

    Which version of ReportBuilder are you using? In my testing with RB 10.03,
    Delphi 2006 and your exact code below, the email button shows up and
    functions correctly.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2006
    10.03
    Does the order in my uses clause matter?
    Larry
  • edited July 2006
    Hi Larry,

    The order of the uses clause should not make a difference however I would
    not rule it out as the cause. I just created a simple example that consists
    of a form with a report and button on it. I added the MyPreviewPlugin file
    to the uses clause before any ReportBuilder units were added.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.