Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

QuickReports - Prepare sometimes causes Printer Setup Dialogue display

Posted on 2010-09-01
4
Medium Priority
?
834 Views
Last Modified: 2013-11-23
I’m using the following code to get number of pages in a document:

  FOWill.QuickRep1.Prepare;

  G_PageCount:=FOWill.QuickRep1.QRPrinter.PageCount;
  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
0
Comment
Question by:farminsure
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:epasquier
ID: 33584354
Have you tried to force programmatically the printer to be used before calling Prepare ?

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

Author Comment

by:farminsure
ID: 33590939
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.PrinterSettings.PrinterIndex := 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
0
 
LVL 25

Accepted Solution

by:
epasquier earned 1000 total points
ID: 33594625
Hum, that smells like some strange bug in QR. Or more than one QRPrinter object is created in your application and there is a mix-up somewhere

I can't open the QRHelp.hlp (after renaming the file ext), maybe there is some file missing that goes with it.

How do you link the QRPrinter object with the QuickRep object ?
I suppose that you are creating your QRPrinter dynamically, why not creating it once only for all your application ? maybe it is a component that can be dropped only once in a DataModule ?

Sorry if I say something stupid in consideration of QR object model, I have not used it with Delphi since about 10 years and really I am only trying guess work here.
0
 

Author Comment

by:farminsure
ID: 33619372
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!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question