Solved

QuickReports - Prepare sometimes causes Printer Setup Dialogue display

Posted on 2010-09-01
4
825 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
Comment Utility
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
Comment Utility
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 250 total points
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now