Print Preview Solution.
I am trying to create a custom Preview Form for my entire application. I
looked at the sample in SimpleView.zip. That example includes a ppReport
on the preview form, and the ppViewer pointing to that. I assume the way
to make that work is to programmatically point the ppViewer to any of my
existing reports at runtime. (And the ppReport is unnecessary on the
preview form).
Since each of my existing reports is descended from a template, maybe I
can code that assignment in the template once to use the form name of
the descendant at runtime - although doing that sounds just beyond my
knowledge.
And finally, I looked at the sample in HidePrintButtonPlugin.zip, (which
name I haven't figured out yet). But it seems to want to make a custom
preview form the default - if I understand it. But the registering
concept is a little unclear. So, what is really necessary?
(By-the-by, I hope to be able to expand a custom preview form as I go,
but the one thing driving this now is the size of the default preview
form. The addition of Maximized is good, but Height and Width
properties would be great. I'm trying to get something between the
current small default and maximized. Maybe in a future release).
looked at the sample in SimpleView.zip. That example includes a ppReport
on the preview form, and the ppViewer pointing to that. I assume the way
to make that work is to programmatically point the ppViewer to any of my
existing reports at runtime. (And the ppReport is unnecessary on the
preview form).
Since each of my existing reports is descended from a template, maybe I
can code that assignment in the template once to use the form name of
the descendant at runtime - although doing that sounds just beyond my
knowledge.
And finally, I looked at the sample in HidePrintButtonPlugin.zip, (which
name I haven't figured out yet). But it seems to want to make a custom
preview form the default - if I understand it. But the registering
concept is a little unclear. So, what is really necessary?
(By-the-by, I hope to be able to expand a custom preview form as I go,
but the one thing driving this now is the size of the default preview
form. The addition of Maximized is good, but Height and Width
properties would be great. I'm trying to get something between the
current small default and maximized. Maybe in a future release).
This discussion has been closed.
Comments
Thanks for the suggestion. There are two different ways to customize the
preview. One is to replace the preview form all together as shown in the
tutorials like rbPrvDlg.pas. The other way is to create and register a
preview plugin which is created from a class registry.
------------------------------------------------------------
Tech Tip: Replacing Built-in Dialogs/Forms in ReportBuilder
------------------------------------------------------------
ReportBuilder has an open architecture for replacing any of the built-in
dialogs. You can replace any of the built-in dialogs by creating a new form
that inherits from an abstract ancestor and then registering it as the new
built-in dialog.
For example to replace ReportBuilder's preview dialog you could
1. Create a new Preview dialog by renaming ReportBuilder's default preview
dialog, then doing a SaveAs to save it under another unit name.
The default dialog resides in RBuilder\Source\ppPrvDlg.pas and the form is
called ppPreviewDialog. You should assign your form a unique name, for
example, myPreviewDlg, and save the unit to another name. Also save the unit
to the directory where your other forms are stored (not RBuilder\Source).
2. Make desired changes.
You will notice that the preview dialog inherits from an ancestor
TppCustomPreviewDialog - this ancestor resides in ppForms.pas (where all the
abstract ancestor forms for ReportBuilder are defined).
3. Register the new form.
Declare an initializtion section at the bottom of the unit:
initialization
ppRegisterForm(TppCustomPreviewer, TmyPreviewDlg);
4. Add the new unit to your project and compile.
Now your preview dialog should be automatically created and destroyed by
ReportBuilder. The two page preview dialog in the
RBuilder\Demos\Reports\Demo.dpro was created this same way. The only
difference is the ppRegisterForm call is in then OnClick event of the
button.
-----------------------------------------
Article: Creating a Preview Plugin
-----------------------------------------
Q: I've followed the tutorials and registered a Preview Form replacement but
that did not affect the TppDesigner's Preview workspace.
A: Do not use the form replacement, but rather, there is a different
architecture built into the preview form that is registered by default.
You will need to register a TppPreview descendent. The class you register
is used to create the preview controls inside the standard print
preview form and the designer preview workspace.
Here is an example of creating a simple custom preview that access the
viewer its been assigned in order to change the page color. You can also
do more advanced operations such as adding and removing buttons and change
the behavior of the preview form. Access the inherited controls via.
protected properties and override the virtual methods in order to customize
behavior.
Open ppPreview.pas and view the TppPreview class as a guide to create a
custom preview descendent.
unit MyPreviewPlugin;
interface
uses
ppPreview;
type
TMyPreviewPlugin = class(TppPreview)
public
procedure BeforePreview; override;
end;
implementation
uses
Graphics;
procedure TMyPreviewPlugin.BeforePreview;
begin
inherited BeforePreview;
Viewer.PageColor := clRed;
end;
initialization
TppPreviewPlugIn.Register(TMyPreviewPlugin);
finalization
TppPreviewPlugIn.UnRegister(TMyPreviewPlugin);
end.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com