RB writes to the spool file. The spool file is then printed. There isn't a native way that RB knows how many pages actually printed to the printer. You will have to research using Win API calls to the printer driver to see if you can find out if all the pages have printed successfully or which number the print job has stopped on. Once RB has generated the entire spool file, the main application continues exectuing after the Report.Print call.
Check out the EnumJobs WinAPI call in the WinAPI help. Look in Delphi's WinSpool.pas file for the Delphi calls that can be made. There is a
{$EXTERNALSYM EnumJobs} function EnumJobs(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob: Pointer; cbBuf: DWORD; var pcbNeeded, pcReturned: DWORD): BOOL; stdcall; {$EXTERNALSYM EnumJobsA} function EnumJobsA(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob: Pointer; cbBuf: DWORD; var pcbNeeded, pcReturned: DWORD): BOOL; stdcall; {$EXTERNALSYM EnumJobsW} function EnumJobsW(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob: Pointer; cbBuf: DWORD; var pcbNeeded, pcReturned: DWORD): BOOL; stdcall;
The JobInfo structure has a PagesPrinted which is what you'll need to reference:
See the main report demo in the printer related section There is one which sets the page range on the page request. Use the OnPrintDialogClose event to check the page request. Look in ppDevice.pas in the TppPageRequest class for the 4 properties it publishes.
uses ppDevice;
procedure TForm1.Button1Click(Sender: TObject); begin ppReport1.Print; end;
procedure TForm1.ppReport1PrintDialogClose(Sender: TObject); begin
I've all ready done, but have notice that Pagerequest object is not update when user define the pages to print. I had to use the PageRequest object of the print dialog.
Comments
native way that RB knows how many pages actually printed to the printer. You
will have to research using Win API calls to the printer driver to see if
you can find out if all the pages have printed successfully or which number
the print job has stopped on. Once RB has generated the entire spool file,
the main application continues exectuing after the Report.Print call.
Check out the EnumJobs WinAPI call in the WinAPI help. Look in Delphi's
WinSpool.pas file for the Delphi calls that can be made. There is a
{$EXTERNALSYM EnumJobs}
function EnumJobs(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob:
Pointer; cbBuf: DWORD;
var pcbNeeded, pcReturned: DWORD): BOOL; stdcall;
{$EXTERNALSYM EnumJobsA}
function EnumJobsA(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob:
Pointer; cbBuf: DWORD;
var pcbNeeded, pcReturned: DWORD): BOOL; stdcall;
{$EXTERNALSYM EnumJobsW}
function EnumJobsW(hPrinter: THandle; FirstJob, NoJobs, Level: DWORD; pJob:
Pointer; cbBuf: DWORD;
var pcbNeeded, pcReturned: DWORD): BOOL; stdcall;
The JobInfo structure has a PagesPrinted which is what you'll need to
reference:
typedef struct _JOB_INFO_1 { // ji1
DWORD JobId;
LPTSTR pPrinterName;
LPTSTR pMachineName;
LPTSTR pUserName;
LPTSTR pDocument;
LPTSTR pDatatype;
LPTSTR pStatus;
DWORD Status;
DWORD Priority;
DWORD Position;
DWORD TotalPages;
DWORD PagesPrinted;
SYSTEMTIME Submitted;
} JOB_INFO_1;
Cheers,
Jim Bennett
Digital Metaphors
------------------------------------------
Tech Tip: Detecting whether Report was
Printed to the Printer
------------------------------------------
The Report.AfterPrint event can be used to
determine whether the report was printed
to the printer (rather than preview, ...).
Example:
procedure TForm1.ppReport1AfterPrint(Sender: TObject);
begin
if (ppReport1.PrinterDevice <> nil) then
ShowMessage('Report was printed to the printer');
end;
Note: If the user cancels the report while it
is running, then the Report.OnCancel event will
fire, followed by the Report.AfterPrint event.
Example:
procedure TForm1.ppReport1Cancel(Sender: TObject);
begin
ShowMessage('Printing cancelled by user');
end;
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
http://www.digital-metaphors.com
info@digital-metaphors.com
range has been selected?
Thanks
marco
sets the page range on the page request. Use the OnPrintDialogClose event to
check the page request. Look in ppDevice.pas in the TppPageRequest class
for the 4 properties it publishes.
uses
ppDevice;
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.Print;
end;
procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
begin
ShowMessage(TppPageRequest(ppReport1.PrintDialog.PageRequest).PageList.Text)
;
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
when user define the pages to print. I had to use the PageRequest object of
the print dialog.
Thanks
marco
coded in my example I posted previously.
You're right, the main reports demo does work differently to configure the
page range before the report prints:
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com