Solved

QuickReports - Prepare sometimes causes Printer Setup Dialogue display

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 167
Mobile Keyboard covers the display of the TMemo 3 86
creating threads in delphi 1 101
Adoquery sql  left join does not work 25 89
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

774 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