TECH TIP: Displaying the AutoSearch Dialog When Using the Report.PrintToDevices Method
Report.PrintToDevices is an advanced method that can be used to send a report to a specific device. This method allows you to take complete control over the printing process. You must create and attach the appropriate devices before making the call to this method.
When using PrintToDevices, the Report.AutoSearchDialog method can be used to display the auto search dialog. The method is implemented as a boolean function. Therefore, if the user presses cancel from the dialog you can decide whether to print.
Example:
uses
ppPrnDev;
procedure TfrmAutoSearch.btnPrintToDeviceClick(Sender: TObject);
var
lPrintDevice: TppPrinterDevice;
begin
lPrintDevice := TppPrinterDevice.Create(Self);
lPrintDevice.Publisher := ppReport1.Publisher;
lPrintDevice.Printer.PrinterSetup := ppReport1.PrinterSetup;
if ppReport1.InitializeParameters and ppReport1.DisplayAutoSearchDialog then
ppReport1.PrintToDevices;
lPrintDevice.Free;
end;