Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Quickreport 4. Access violation in qrprinter printing from page to page

494 views
Skip to first unread message

Roberto Nicchi

unread,
May 7, 2008, 5:43:35 AM5/7/08
to
I'm porting my application from Delphi 7 to Delphi 2007 and have replaced QR
3 with QR 4 (standard)

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);

Roberto Nicchi

unread,
May 19, 2008, 5:49:07 AM5/19/08
to
For who is interested in the following code should works:

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...

0 new messages