In my application i have some reports that are created using a Tqrprinter
Have also a custom preview with a print button.
If i print all pages i have no problem but if i want to print a page
selection (from page to page) have an access violation.
I'm using the code above to print from page to page. An access violation
occurs in the PRINT line. Does someone have a working code ?
thank you
Roberto
SrcFileName := TempFileName;
DestFileName := TempFileName;
CopyFileName := TempFileName;
// Save the report to a file so that we can work with it.
qrprinter.Save(SrcFileName);
// Build a new file with the range of pages that was selected
RangeFromQRP(SrcFileName, DestFileName, printdialog.FromPage,
printdialog.ToPage);
with TQRPrinter.Create(nil) do
begin
printerindex := printer.printerIndex;
pp:=Tprinterparams.create;
try
GetPrinterParams(pp);
qrprinter.UseCustomBinCode:=true;
qrprinter.CustomBinCode := pp.Bin;
finally
pp.free;
end;
// If we want more than 1 copy, we just repeat the pages in the
// list. This will make sure that only a single print job is
// issued.
if printdialog.Copies > 1 then begin
CopyList := TStringList.Create;
for i := 1 to printdialog.copies do
CopyList.Add(DestFileName);
CombineQRP(CopyFileName, CopyList);
CopyList.Free;
Load(CopyFileName);
end
else
Load(DestFileName);
Print; <...................... ACCESS VIOLATION HERE
Free;
end;
DeleteFile(CopyFileName);
DeleteFile(DestFileName);
DeleteFile(SrcFileName);
var
i: integer;
RepeatPrint: boolean;
begin
printer.PrinterIndex := qrprinter.printerindex;
printdialog.options:=[poPagenums];
printdialog.frompage:=1;
printdialog.minpage:=1;
printdialog.topage:=QRPrinter.PageCount;
printdialog.maxpage:=QRPrinter.PageCount;
if printdialog.execute then
begin
qrprinter.PrinterIndex:=printer.PrinterIndex;
if printdialog.PrintRange=prPagenums then
begin
qrprinter.FirstPage:=printdialog.FromPage;
qrprinter.lastpage:=printdialog.ToPage;
end
else begin
qrprinter.FirstPage:=0;
qrprinter.lastpage:=0;
end;
qrprinter.Copies:=printdialog.Copies;
repeatprint:=false;
if printdialog.copies>1 then
if qrprinter.copies=1 then repeatprint:=true;
if repeatprint then
begin
for i:=1 to printdialog.copies do
qrprinter.Print;
end
else qrprinter.Print;
end;
end;
"Roberto Nicchi" <soft...@masterinformatica.net> ha scritto nel messaggio
news:4821...@newsgroups.borland.com...