Solved

QuickReports - Prepare sometimes causes Printer Setup Dialogue display

Posted on 2010-09-01
4
826 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

16 Experts available now in Live!

Get 1:1 Help Now