Possible to Expose CanPrint event in End User Rap?
I would like to allow my end users to use an inputbox passthrough function
to prompt the user for a value. This works great until the user clicks the
cancel button on the inputbox. The report is displayed regardless of the ok
or cancel. I read the problem in another posting. It mentioned that the
OnCreate event fires after the report has already started to print.
Is there are way to expose/create an event that is before the print of the
report? A CanPrint type event would be great. The user could then decide for
themselves if the report should be displayed. If this cannot be done, can
this be an enhancement that would go in a future version of RB?
to prompt the user for a value. This works great until the user clicks the
cancel button on the inputbox. The report is displayed regardless of the ok
or cancel. I read the problem in another posting. It mentioned that the
OnCreate event fires after the report has already started to print.
Is there are way to expose/create an event that is before the print of the
report? A CanPrint type event would be great. The user could then decide for
themselves if the report should be displayed. If this cannot be done, can
this be an enhancement that would go in a future version of RB?
This discussion has been closed.
Comments
fires before the report prints to allow/disallow the print process to
continue. An OnPrintQuery event much like the form's OnCloseQuery could be
placed on the ToDo list. Thanks for the suggestion.
If you are explicitly calling Report.Print, you should rather call
Report.PrintToDevices so that you can manage the print process and not
create an output device.
Another alternative is if you are using the report explorer, then create a
custom report explorer form and add you code to disallow the call to print
when the user double clicks a report in the report explorer. There is a
custom report explorer demo in the tutorials section of our RBuilder
installation.
If you want to modify our source to have a new event, open up ppProd.pas and
add a communication event to do this. You are using RAP and will have to use
the communicator to do this so you can hook into the report via its
communicator interface for event notification and not use Delphi event
handlers. This way you can still use RAP, because you do not want to change
the interface section of TppProducer. Make a call on the communicator
interface that the producer inherits from and call SendEventNotify(Self,
aEventIDYouMakeUp, lParams). You'll have to create an lParams: TraParamList.
The class is located in the ppRTTI.pas unit. Pass any integer higher than
those found for the ci* event ID constants in ppTypes.pas. Then you can get
a boolean back from the lParams and selectively continue the execution in
the call to TppProducer.Print method before it calls PrintToScreen or
PrintToPrinter. For an example of using a TraParamList to pass a boolean
value using a TppCommunicator event mechanism, check out
TppOutlineViewer.SetOutlineVisible in ppOutlineViewer.pas. To listen for
this event, create a TppComunicator and call
Report.AddEventNotify(lMyCommunicatorObject). Then in the
lMyCommunicatorObject's OnEventNotifyEvent handler, catch the
aEventIDYouMakeUp compared to the aEventID parameter of this evnt handler.
Then you can set the aParams[0] object's boolean value to true or false.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com