When looking at the preview screen I would like to place a button on the
form in which the user can quickly print the current page.
Is there a way to only print the currently displayed page without displaying
the printer dialog box?
Thanks in advance,
Rodger
Comments
Check out demo 124 (dm0124.pas) located in the \RBuilder\Demos\1. Reports...
directory for an example on how to control the page range when printing a
report. In the Report.BeforePrint event you will want to use the following
code:
ppTextToPageList('1,1', Report.PrinterDevice.PageList, True);
as shown in the demo.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
like the following:
FPrintCurrentPage := TSpeedButton.Create(lButtonBar);
FPrintCurrentPage.Parent := lButtonBar;
FPrintCurrentPage.Flat := True;
FPrintCurrentPage.Left := FPrintButton.width;
FPrintCurrentPage.Top := 2;
FPrintCurrentPage.ParentShowHint := True;
FPrintCurrentPage.Hint := 'Print current page (default printer)';
FPrintCurrentPage.Glyph.LoadFromResourceName(HInstance,
'CURPAGEBTN');
FPrintCurrentPage.OnClick := PrintCurrentPageButtonClickEvent;
and then defined
procedure TMyPreviewPlugin.PrintCurrentPageButtonClickEvent(Sender:
TObject);
var lPrinterDevice: TppPrinterDevice;
lPage: TppPage;
begin
// print current page
lPage := Viewer.CurrentPage;
lPrinterDevice := TppPrinterDevice.Create(nil);
lPrinterDevice.Printer.PrinterSetup.PrinterName :=
FCurrentPrinterName.Text;
lPrinterDevice.StartJob;
lPrinterDevice.PageRequest.PageRequested := lPage.AbsolutePageNo;
lPrinterDevice.PageRequest.PageSetting := psSinglePage;
lPrinterDevice.ReceivePage(lPage);
lPrinterDevice.EndJob;
lPrinterDevice.Free;
end;