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

Accesing public properties on a custom previewer

edited September 2011 in General
Hi,

I've created a custom previewer, much along the lines of the demo (i.e,
TMyPreviewPlugin = class(TppPreview)...) and I've added an extra button to
the preview form (which I default to invisible in the CreateToolbarItems
block)...
Private
FCustomButton: TppTBXItem;

I have a corresponding public property....

property CustomButtonVisible: boolean read fCustomButtonVisible write
SetCustomButtonVisible;

where SetCustomButtonVisible procedure sets the visibility of fCustomButton.

procedure TMyPreviewPlugin.SetCustomButtonVisible(value: Boolean);
begin
fCustomButtonVisible := Value;
if Assigned(fCustomButton) then
begin
fCustomButton.Visible := fCustomButtonVisible;
fCustomButton.Invalidate;
end;
end;


How can I, and, when do I access this property from my delphi form
containing a report? I've tried using the report's OnPreviewFormCreate
event but this doesn't seem to trigger for me (break point is never reached)
. I had more luck with the reports OnAssignPreviewFormSettings event

procedure TFormrptrbCRMReports.ppReport1AssignPreviewFormSettings(
Sender: TObject);
begin
TMyPreviewPlugIn(ppReport1.PreviewForm).CustomButtonVisible := True;
end;

when this event fires and I trace into the code for SetCustomButtonVisible
above the Assigned(fCustomButton) returns false?? What am I doing wrong
please?

TIA



Comments

  • edited September 2011
    Willie,

    The Report.PreviewForm property does not represent a TppPreview object.
    It is the preview form itself. (see the ppPrvDlg.pas file).

    The TppPrintPreview object (or preview form) contains some pass thru
    properties for accessing each existing button as well as a pass thru to
    the toolbar. You can use the toolbar property to access your custom button.

    uses
    ppPrvDlg;

    TppPrintPreview(ppReport1.PreviewForm).Toolbar[MyButtonIndex].Visble :=
    False;

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2011
    Thanks Nico,

    Ummm I'm not sure I understand this but anyway I've tried your suggestion
    and figured out a work-around, thanks for that.

    One question though please, in my Plugin object I have some public
    properties/methods declared, is it not actually possible to access these
    from a report form?




  • edited September 2011
    Hi Willie,

    The previewer consists of the following parts:
    - TppPrintPreview: The preview form
    - TppPreview: The default preview plugin (creates toolbars, viewer,
    menus, etc. on the preview form)
    - TppPreviewPlugin: Manages and registers preview plugins.


    The Report object itself only has access to the preview form, not the
    preview plugin. This means that any custom routines/properties created
    in the plugin will not be accessible.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2011
    Thanks Nico.

This discussion has been closed.