You can create a custom preview window by using the Preview Plugin archetecture of ReportBuilder. See the example below on how to create a custome preview window with the print button disabled.
See the article below for more explanation on the Preview Plugin architecture.
----------------------------------------- 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;
Which version of ReportBuilder/Delphi are you using? I compiled and ran the code I sent you just before I sent it and it seemed to work correctly. You will insert the code inside the preview pugin code, like in the example I sent you. Then you need to register this plugin code using the plugin registration routines included with the TppPreview object. See the ppPreview.pas file for the implementation of these methods.
Ok, that makes more since now. The plugin architecture was not added until RB 7. You will need to create a replacement preview form and register that with ReportBuilder to successfully customize the previewer. Below is an article that may help. There is also a tutorial on creating a replacement forms in ReportBuilder. This tutorial is located in the \RBuilder\Tutorials\Complete\II. Applications\04. End-User with Custom Explorer\... directory.
------------------------------------------------------------ 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 print dialog you could
1. Create a new Print dialog by renaming ReportBuilder's default print dialog, then doing a SaveAs to save it under another unit name.
The default dialog resides in RBuilder\Source\ppPDlg.pas and the form is called ppPrintDialog. You should assign your form a unique name, for example, myPrintDlg, 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 print dialog inherits from an ancestor TppCustomPrintDialog - 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:
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.
Comments
You can create a custom preview window by using the Preview Plugin
archetecture of ReportBuilder. See the example below on how to create a
custome preview window with the print button disabled.
http://www.digital-metaphors.com/tips/PreviewPrintBtnDisabled.zip
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Sorry, wrong link...
http://www.digital-metaphors.com/tips/PreviewerHidePrintButton.zip
See the article below for more explanation on the Preview Plugin
architecture.
-----------------------------------------
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.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
so I used the below code to do my own.
but where would I insert code to make the printbutton visible or enabled set
to false?
thanks, joey
even the new link would not compile.
Which version of ReportBuilder/Delphi are you using? I compiled and ran the
code I sent you just before I sent it and it seemed to work correctly. You
will insert the code inside the preview pugin code, like in the example I
sent you. Then you need to register this plugin code using the plugin
registration routines included with the TppPreview object. See the
ppPreview.pas file for the implementation of these methods.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I get this error on compile
[Error] MyPreviewPlugin.pas(25): Declaration of 'Create' differs from
previous declaration
constructor Create(aOwner: TComponent); override; is hilited in red
Ok, that makes more since now. The plugin architecture was not added until
RB 7. You will need to create a replacement preview form and register that
with ReportBuilder to successfully customize the previewer. Below is an
article that may help. There is also a tutorial on creating a replacement
forms in ReportBuilder. This tutorial is located in the
\RBuilder\Tutorials\Complete\II. Applications\04. End-User with Custom
Explorer\... directory.
------------------------------------------------------------
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 print dialog you could
1. Create a new Print dialog by renaming ReportBuilder's default print
dialog, then doing a SaveAs to save it under another unit name.
The default dialog resides in RBuilder\Source\ppPDlg.pas and the form is
called ppPrintDialog. You should assign your form a unique name, for
example, myPrintDlg, 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 print dialog inherits from an ancestor
TppCustomPrintDialog - 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(TppCustomPrintDialog, TMyPrintDialog);
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.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com