Board index » cppbuilder » Error: Printer index out of range

Error: Printer index out of range


2005-06-10 08:02:30 PM
cppbuilder44
Hi,
I received an error "printer index out of range" while printing with
QuickReport.
My code is:
QuickRep1->PrinterSetup();
QuickRep1->Print();
If I print without doing PrinterSetup(), no problem.
What could be the problem?
Thanks in advance,
Anil
P.S.:I'm using Borland C++ builder 6 over Windows 2000.
 
 

Re:Error: Printer index out of range

Do you actually have printers on installed on the system? Is the
default printer online when you do this? In the back of my mind,
there's a bug in the printersetupdialog that causes a problem (many
versions ago). What I ended up doing was this:
Quote
bool PrinterExists = (Printer()->Printers->Count); // Check for existence of a printer
TPrinterSetupDialog *PrinterSetupDialog = new TPrinterSetupDialog(this);
TPrintDialog *PrintDialog = new TPrintDialog(this);
if (PrinterExists) { // Create Printer Dialogs if a printer exists
PrintDialog->OnShow = PrintDialogShow;
PrintDialog->Copies = 1;
PrintDialog->MinPage = 1;
PrintDialog->MaxPage = 2;
PrintDialog->Options << poPrintToFile << poPageNums;
PrintDialog->PrintRange = prPageNums;
}
Don't know if this is your problem, but it might be related.
David Erbas-White
Anil Sahin wrote:
Quote
Hi,

I received an error "printer index out of range" while printing with
QuickReport.

My code is:

QuickRep1->PrinterSetup();

QuickRep1->Print();

If I print without doing PrinterSetup(), no problem.

What could be the problem?

Thanks in advance,

Anil

P.S.:I'm using Borland C++ builder 6 over Windows 2000.