{*************************************************************************** *** * ** I N I T I A L I Z A T I O N / F I N A L I Z A T I O N * {*************************************************************************** ***}
Is there a way to use the custom previewer ONLY in certain areas of my program ( for instance in the Reports.Pas unit and the InvReports.Pas unit only ) ???
The registration mechanism is called in the intialization finalization sections of a unit, but you can call these methods anytime you want. Before you call the Report.Print in one of your pas files, you can unregister the current previewer, then register a new previewer, call print, then unregister the new previewer and reregister the old previewer.
Instead of registering the previewer in the intialization/finalization section, do it only in the few cases where you need a special previewer:
Comments
to call you own print routine.
procedure PerformPreviewAction(aPreviewAction: TppPreviewActionType);
Register you new preview class and you're good to go.
...
{@TppMyPreview}
TppMyPreview = class(TppPreview)
private
procedure MyPrint;
public
procedure PerformPreviewAction(aPreviewAction: TppPreviewActionType);
override;
end; {class, TppMyPreview}
implementation
uses
ppTypes;
procedure TppMyPreview.MyPrint;
begin
{do your printing code}
beep;
end;
procedure TppMyPreview.PerformPreviewAction(aPreviewAction:
TppPreviewActionType);
begin
if (aPreviewAction = paPrint) then
MyPrint
else
inherited PerformPreviewAction(aPreviewAction);
end; {procedure, PerformPreviewAction}
{***************************************************************************
***
*
** I N I T I A L I Z A T I O N / F I N A L I Z A T I O N
*
{***************************************************************************
***}
initialization
TppPreviewPlugin.UnRegister(TppPreview);
TppPreviewPlugIn.Register(TppMyPreview);
finalization
TppPreviewPlugIn.UnRegister(TppMyPreview);
TppPreviewPlugIn.Register(TppPreview);
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks - that makes sense. How does my ppReport component know to use
the descendent previewer ???
Neil Huhta
calls in the initializatoin/finalization section:)
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Is there a way to use the custom previewer ONLY in certain areas of my
program ( for instance in the Reports.Pas unit and the InvReports.Pas unit
only ) ???
Neil
sections of a unit, but you can call these methods anytime you want. Before
you call the Report.Print in one of your pas files, you can unregister the
current previewer, then register a new previewer, call print, then
unregister the new previewer and reregister the old previewer.
Instead of registering the previewer in the intialization/finalization
section, do it only in the few cases where you need a special previewer:
..
TppPreviewPlugin.UnRegister(TppPreview);
TppPreviewPlugIn.Register(TppMyPreview);
ppReport1.Print;
TppPreviewPlugIn.UnRegister(TppMyPreview);
TppPreviewPlugIn.Register(TppPreview);
..
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com