farminsure
asked on
QuickReports - Prepare sometimes causes Printer Setup Dialogue display
I’m using the following code to get number of pages in a document:
FOWill.QuickRep1.Prepare;
G_PageCount:=FOWill.QuickR ep1.QRPrin ter.PageCo unt;
FOWill.QRLabel54.Caption := ' of ' + IntToStr(G_PageCount);
In a couple of places it will display the Printer Select Dialogue, where in others it does not. I use this same technique in several places in the program and it works great.
What can I be doing that will cause it to display this dialogue? I have put a break point on the “Prepare” statement and the one following it “G_PageCount…” and the select dialogue appears before it gets to the second statement.
Yet in other places in the program this works fine without the select dialogue being displayed, and I can see no differences in code in the ones that work and ones that don't I can’t find any posts or documentation that tells me why this would be happening.
Regards,
-- Jim Lowary
FOWill.QuickRep1.Prepare;
G_PageCount:=FOWill.QuickR
FOWill.QRLabel54.Caption := ' of ' + IntToStr(G_PageCount);
In a couple of places it will display the Printer Select Dialogue, where in others it does not. I use this same technique in several places in the program and it works great.
What can I be doing that will cause it to display this dialogue? I have put a break point on the “Prepare” statement and the one following it “G_PageCount…” and the select dialogue appears before it gets to the second statement.
Yet in other places in the program this works fine without the select dialogue being displayed, and I can see no differences in code in the ones that work and ones that don't I can’t find any posts or documentation that tells me why this would be happening.
Regards,
-- Jim Lowary
ASKER
I did add code to set the printer before the prepare statement Using this code below:
// Test setting printer first
nInd := Printer.Printers.IndexOf(' PDF995');
if nInd >= 0 then
Begin
Printer.PrinterIndex := nInd;
FOTill.QuickRep1.PrinterSe ttings.Pri nterIndex := Printer.PrinterIndex;
End;
What that did was now the Printer Selection Window opens with that printer selected rather than my default printer. The Quick Reports people seem to think I have a memory leak and am not freeing the qrprinter is not freed. But the code that I sent them shows I have a QRPrinter.Free; and a QRPrinter := nil; according to their examples of how to do this.
Since this same code works in other forms fine repeatedly, but fails the first time in this form even after program as been started over and this is the first thing done. I can't see a memory leak, at least not from what I'm doing.
Also in this form if I do a preview I get the printer selection dialogue just like on the Prepare. I tried moving my procedure around in the code thinking if it was a memory problem that I could at least see some different results, but that did not have any effect either. Neither did changing the order of the procedure statments in this form.
I'm at a loss again as to what else to try to make this work or even find what might be causing the problem.
QRHELP.txt
// Test setting printer first
nInd := Printer.Printers.IndexOf('
if nInd >= 0 then
Begin
Printer.PrinterIndex := nInd;
FOTill.QuickRep1.PrinterSe
End;
What that did was now the Printer Selection Window opens with that printer selected rather than my default printer. The Quick Reports people seem to think I have a memory leak and am not freeing the qrprinter is not freed. But the code that I sent them shows I have a QRPrinter.Free; and a QRPrinter := nil; according to their examples of how to do this.
Since this same code works in other forms fine repeatedly, but fails the first time in this form even after program as been started over and this is the first thing done. I can't see a memory leak, at least not from what I'm doing.
Also in this form if I do a preview I get the printer selection dialogue just like on the Prepare. I tried moving my procedure around in the code thinking if it was a memory problem that I could at least see some different results, but that did not have any effect either. Neither did changing the order of the procedure statments in this form.
I'm at a loss again as to what else to try to make this work or even find what might be causing the problem.
QRHELP.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found the problem after tracing thru quick reports components. Seems that two of the "failing" forms has a before print event to display the Printer dialogue? Duh! Inherited code. Thanks for your suggestions!
Unfortunately I don't have QuickReport, but maybe if you could find QR help file and post it here I would be able to find how to do that.