Solved

QuickReports - Prepare sometimes causes Printer Setup Dialogue display

Posted on 2010-09-01
4
830 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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