Modifying the Standard Rave 4.0 and earlier Preview Form to suit your own needs

Category

Code Based - General

Question

I want to replace the default preview form that comes with Rave. How would I do that?

Solution

There are two approaches you can use to modify the preview screen:

The first one is that you can modify the files RPPREFRM.PAS and RPPREFRM.DFM (found in the source subdirectory) to suit your particular application. The disadvantage to using this approach is that when new patches for Rave are released, they might not recognize the modifications to the source code and you might run into problems.

The second approach, which is described below, is more flexible and, hence, more desirable:

1. Copy RPPREFRM.PAS and RPPREFRM.DFM to new files, let's call them MYPREV.PAS and MYPREV.DFM.
2. Open MYPREV.PAS inside Delphi (preferrably with your project already open) and rename the unit heading to MYPREV.
3. Rename the form associated with MYPREV.PAS to MyPrevForm in the Object Inspector.
4. Add the unit MYPREV to your project using the project manager.
5. Recompile your project using Build All.
6. Open the file RPSYSTEM.PAS from the source subdirectory and copy the contents of the procedure OverridePreviewProc from there into the event called OverridePreview for the ReportSystem component.
7. Replace all occurrences of TRPPreviewForm with TMyPrevForm throughout the procedure (this will be done in the OverridePreview event for the ReportSystem component).
8. Make the following changes in the same OverrideXxxxx event:
Change FTitlePreview to TitlePreview
Change FFormWidth to FormWidth
Change FFormHeight to FormHeight
Change FFormState to FormState
9. Add MYPREV to the uses statement in your project.

There it is. You now have a customized version of the preview form. You can modify it as you wish. Remember that the above procedure could have also been used to assign your own preview form to the ReportSystem component