Page 1 of 1

SRVPrint - there is no default printer currently selected

Posted: Tue Aug 14, 2018 7:01 am
by BoD
Good day!

If the printer is not completely removed from the system when working with the SRVPrint component,
appears error "There is no default printer currently selected" .
A similar error was described in 2012 (/forums/viewtopic.php?t=5488) - still no changes in the source code.

:idea: How to reproduce the error:
  1. The system should not have printers (disconnect and remove all).
  2. Create a new printer (for example, Microsoft XPS) on the unused port (LPT1...).
  3. Create a new VCL – Delphi application and place the SRVPrint component on the form.
  4. Save the project and close Delphi.
  5. Print something (for example, a test page) - the job gets into the print queue.
  6. Remove the printer (it will disappear from the list of printers)
  7. Start Delphi and open the saved project...Error :!:
The problem in the used module Printers.
Which, in this situation, it returns Printer.Printers.Count = 1
But any references to Printer objects (for example, Printer.PrinterIndex, etc.) - generates an error.

Used with:
Delphi 2010, XE6
TRichView 17.2.1
ScaleRichView 8.1.2

Re: SRVPrint - there is no default printer currently selected

Posted: Tue Aug 14, 2018 5:18 pm
by Sergey Tkachenko
I thought that checking for Printers.Count = 0 solved the problem, and these changes there made...

I cannot reproduce the error in the scenario you described. In my test, Printers.Count = 0 in this case.
What version of Windows do you use?

Re: SRVPrint - there is no default printer currently selected

Posted: Wed Aug 15, 2018 4:41 am
by BoD
Thank you for answer.
I'm use windows 10 x64

Simplest way to reproduce the error:
The system should not have printers (disable / delete all).
Delphi is not running.
  1. Add a new printer (for example, Microsoft XPS) on the unused port (LPT1...).
  2. Send something (for example, a test page) to print - the job gets into the print queue.
  3. Remove the printer (it will disappear from the list of printers)
  4. Create a new Delphi VCL – application and try to place the SRVPrint component on the form...Error

Re: SRVPrint - there is no default printer currently selected

Posted: Wed Aug 15, 2018 8:33 am
by Sergey Tkachenko
I sent a fix by a private message, please test it.