Discussion:
Print range / Using ShowPrintDialog in Rave
(too old to reply)
Jan Finell
2007-11-09 13:02:47 UTC
Permalink
Hi all,

We are using Rave for some of the reports we are creating in our
application. Our customer would now like to have the print setup
dialog translated into their language of choice. I've looked into
using the ShowPrintDialog/ShowPrinterSetupDialog since this would
AFAIK use the standard Windows print setup dialog instead of the Rave
one (this is the preferred solution).

I was able to get the ShowPrinterSetupDialog to work as expected, but
I can't seem to be able to figure out how to use the ShowPrintDialog.
The reason why I'm not happy with the ShowPrinterSetupDialog is that
it does not have the "Print range" option. I'm currently have this
code under a TButton.OnClick event:

RvSys.DefaultDest := rdPrinter;
RvSys.RenderObject := RvRenderPrinter1;
RvSys.SystemSetups := [ssAllowCopies, ssAllowCollate,
ssAllowDuplex, ssAllowDestPreview,
ssAllowDestPrinter, ssAllowDestFile,
ssAllowPrinterSetup, ssAllowPreviewSetup];

if TBaseReport(RvRenderPrinter1).ShowPrinterSetupDialog then
begin
RvRenderPrinter1.IgnoreFileSettings := True;
RvSys.Execute;
end;

Not sure if this is correct way to do it, but at least this works!
Anyway, if I now replace the ShowPrinterSetupDialog with the
ShowPrintDialog, I'll end up with an Access Violation. So my question
is now, how/when should the ShowPrintDialog be called so that it'll
work as intended?

I also noticed when playing around with the RaveDemo that the Print
setup dialog displayed when clicking Print in the Rave Preview UI
differs from the one shown when clicking the 'Print' button on the
main page (RaveDemo.exe). The first one has a print range option
(Pages from...to) whereas the second one does not have this. I could
not find any documentation or examples on how to enable the 'print
range' possibility in the Rave's printer setup dialog?!

Another issue I noticed, is that the "Number of copies" option does
not work at all. Ie. it does not matter what you enter in this box
(using the standard Rave printer setup dialog), it'll always only
print one copy (maybe this is a printer driver problem and not related
to Rave in anyway?!)

We are running Delphi 7 and the Rave version 5.0.8 (on Windows XP/
2000).

I've sent this exact same message (email) to the ***@nevrona.com,
but no reply from them yet.

Cheers,

Jan Finell
Jan Finell
2007-11-12 06:10:11 UTC
Permalink
Post by Jan Finell
Hi all,
We are using Rave for some of the reports we are creating in our
application. Our customer would now like to have the print setup
dialog translated into their language of choice. I've looked into
using the ShowPrintDialog/ShowPrinterSetupDialog since this would
AFAIK use the standard Windows print setup dialog instead of the Rave
one (this is the preferred solution).
I was able to get the ShowPrinterSetupDialog to work as expected, but
I can't seem to be able to figure out how to use the ShowPrintDialog.
The reason why I'm not happy with the ShowPrinterSetupDialog is that
it does not have the "Print range" option. I'm currently have this
RvSys.DefaultDest := rdPrinter;
RvSys.RenderObject := RvRenderPrinter1;
RvSys.SystemSetups := [ssAllowCopies, ssAllowCollate,
ssAllowDuplex, ssAllowDestPreview,
ssAllowDestPrinter, ssAllowDestFile,
ssAllowPrinterSetup, ssAllowPreviewSetup];
if TBaseReport(RvRenderPrinter1).ShowPrinterSetupDialog then
begin
RvRenderPrinter1.IgnoreFileSettings := True;
RvSys.Execute;
end;
Not sure if this is correct way to do it, but at least this works!
Anyway, if I now replace the ShowPrinterSetupDialog with the
ShowPrintDialog, I'll end up with an Access Violation. So my question
is now, how/when should the ShowPrintDialog be called so that it'll
work as intended?
I also noticed when playing around with the RaveDemo that the Print
setup dialog displayed when clicking Print in the Rave Preview UI
differs from the one shown when clicking the 'Print' button on the
main page (RaveDemo.exe). The first one has a print range option
(Pages from...to) whereas the second one does not have this. I could
not find any documentation or examples on how to enable the 'print
range' possibility in the Rave's printer setup dialog?!
Another issue I noticed, is that the "Number of copies" option does
not work at all. Ie. it does not matter what you enter in this box
(using the standard Rave printer setup dialog), it'll always only
print one copy (maybe this is a printer driver problem and not related
to Rave in anyway?!)
We are running Delphi 7 and the Rave version 5.0.8 (on Windows XP/
2000).
but no reply from them yet.
Cheers,
Jan Finell
Replying to my own post...

I got this reply from Nevrona Support:

The RvRenderPrinter component cannot be typecast to a TBaseReport
object =
which is why you are getting an error. You can still get access to
the =
underlying printer object if you include the unit RpDevice and access
=
the RpDev object.

uses
RpDevice;

if RpDev.PrinterSetupDialog then begin
end;

or

var
FirstPage, LastPage: integer;

FirstPage :=3D 1;
LastPage :=3D 9999;
if RpDev.SimplePrintDialog(FirstPage, LastPage) then begin
// Set print range for firstpage to lastpage on RvSystem component
then =
execute report
end;

There's many other functions in the RpDev object as well.

If you would like to override the setup/status/preview dialogs you can
=
also visit this tip for an example:

http://www.nevrona.com/Default.aspx?tabid=3D93
Jan Finell
2007-11-12 13:20:19 UTC
Permalink
Post by Jan Finell
Post by Jan Finell
Hi all,
We are using Rave for some of the reports we are creating in our
application. Our customer would now like to have the print setup
dialog translated into their language of choice. I've looked into
using the ShowPrintDialog/ShowPrinterSetupDialog since this would
AFAIK use the standard Windows print setup dialog instead of the Rave
one (this is the preferred solution).
I was able to get the ShowPrinterSetupDialog to work as expected, but
I can't seem to be able to figure out how to use the ShowPrintDialog.
The reason why I'm not happy with the ShowPrinterSetupDialog is that
it does not have the "Print range" option. I'm currently have this
RvSys.DefaultDest := rdPrinter;
RvSys.RenderObject := RvRenderPrinter1;
RvSys.SystemSetups := [ssAllowCopies, ssAllowCollate,
ssAllowDuplex, ssAllowDestPreview,
ssAllowDestPrinter, ssAllowDestFile,
ssAllowPrinterSetup, ssAllowPreviewSetup];
if TBaseReport(RvRenderPrinter1).ShowPrinterSetupDialog then
begin
RvRenderPrinter1.IgnoreFileSettings := True;
RvSys.Execute;
end;
Not sure if this is correct way to do it, but at least this works!
Anyway, if I now replace the ShowPrinterSetupDialog with the
ShowPrintDialog, I'll end up with an Access Violation. So my question
is now, how/when should the ShowPrintDialog be called so that it'll
work as intended?
I also noticed when playing around with the RaveDemo that the Print
setup dialog displayed when clicking Print in the Rave Preview UI
differs from the one shown when clicking the 'Print' button on the
main page (RaveDemo.exe). The first one has a print range option
(Pages from...to) whereas the second one does not have this. I could
not find any documentation or examples on how to enable the 'print
range' possibility in the Rave's printer setup dialog?!
Another issue I noticed, is that the "Number of copies" option does
not work at all. Ie. it does not matter what you enter in this box
(using the standard Rave printer setup dialog), it'll always only
print one copy (maybe this is a printer driver problem and not related
to Rave in anyway?!)
We are running Delphi 7 and the Rave version 5.0.8 (on Windows XP/
2000).
but no reply from them yet.
Cheers,
Jan Finell
Replying to my own post...
The RvRenderPrinter component cannot be typecast to a TBaseReport
object =
which is why you are getting an error. You can still get access to
the =
underlying printer object if you include the unit RpDevice and access
=
the RpDev object.
uses
RpDevice;
if RpDev.PrinterSetupDialog then begin
end;
or
var
FirstPage, LastPage: integer;
FirstPage :=3D 1;
LastPage :=3D 9999;
if RpDev.SimplePrintDialog(FirstPage, LastPage) then begin
// Set print range for firstpage to lastpage on RvSystem component
then =
execute report
end;
There's many other functions in the RpDev object as well.
If you would like to override the setup/status/preview dialogs you can
=
http://www.nevrona.com/Default.aspx?tabid=3D93
A working solution (at least this worked for me):

var
rec : TPrintDialogRec;

begin

rec.FromPage := 1;
rec.ToPage := RvRender.Pages;
rec.MinPage := 1;
rec.MaxPage := RvRender.Pages;
rec.Options := [poPageNums, poWarning, poHelp];

if RpDev.PrintDialog(rec) then
begin
RvSys.SystemPrinter.Copies := rec.Copies; // This does, for some
reason, not work!

if rec.PrintRange <> prAllPages then
begin
RvSys.SystemPrinter.FirstPage := rec.FromPage;
RvSys.SystemPrinter.LastPage := rec.ToPage;
end;

RvRenderPrinter1.IgnoreFileSettings := True;
RvProject.Execute;
end;

end;

Loading...