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

Tpp Viewer

edited June 2016 in General
Guys:

I wrote a custom previewer inside a unit - what I have it doing is
calling my own procedure inside that unit - and it has worked great for many
years.

Procedure PerformPreviewAction
calls procedure PrintRawReport if boolean variable fLaserPrint
is false

It can do this because Procedure PrintRawReport and variable
fLaserReport are in the same unit as Procedure PerformPreviewAction is


Here is my problem - I would really like to encapsulate Procedure
PrintRawReport and variable fLaserReport into a class - once this is done
then I can't figure out how to get my custom TppViewer event
PerformViewAction to be able to see the PrintRawReport procedure or the
fLaserReport property

My educated guess is that I need to move my TppRawReview Class up into
a unit that can see the created instance of the class which has the property
fLaserReport and Procedure PrintRawReport - is that the correct way to go
??? Thank you.

Neil Huhta
Profit Monster Data Systems





TppRawPreview = Class(TppPreview)

private
Procedure PrintRawFromPreview;
public
procedure BeforePreview; Override;
Procedure PerformPreviewAction(aPreviewAction: TppPreviewActionType);
Override;
end;


Procedure
TppRawPreview.PerformPreviewAction(aPreviewAction:TppPreviewActionType);
begin
if (aPreviewAction=paPrint) Then
begin
If (fLaserPrint=True) Then //or (PrtRaw.RawPrint<>True) Then
inherited
Else
PrintRawReport;
end
Else
inherited PerformPreviewAction(aPreviewAction);
end;


Now - I am re-writing my code - and the procedure that the tpp

Comments

  • edited June 2016
    Hi Neil,

    One option would be to create an instance of your encapsulation class in
    your custom Preview and use its routines/properties as needed.

    For instance, in the constructor of the custom preview:

    FPrintUtils = TMyPrintUtils.Create(...);

    and in the PerformPreviewAction:

    if FPrintUtils.LaserPrint then
    FPrintUtils.PrintRawReport;

    Another option would be to make PrintRawReport a class routine so it can
    be accessed without an object instance.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2016
    Nico:

    It was definitely a scope problem and a location problem - once I made
    my custom print routines an object - the Custom previewer had to be moved to
    an area where it could have access to the instantiated object - therefore I
    just moved the custom previewer into its own unit and accessed the routine
    thru the instantiated printer object and it worked perfectly.

    Thank you.

    Neil Huhta

This discussion has been closed.