Refreshing printers
Hi,
I've found that once my program is already running, changing the name of a printer in Windows and then trying to print to it results in an Exception when using TfrxReport
(EInvalidOperation) Canvas does not allow drawing.
In my specific instance, the first time this happens, it causes this exception, and then on each subsequent time it happens, my program then puts up an alert window saying "Printer selected is not valid" which then hangs until acknowledged and then throws the same Exception as above. This is a problem, as the code is being deployed as a windows service application, so the alert window is hidden, and the service freezes.
Is there a way to refresh the Printer list before I generate each report?
Also - is there a way to force these popup alert windows to raise exceptions instead? I've already tried setting TfrxReport.EngineOptions.SilentMode:=True, and TfrxReport.EngineOptions.NewSilentMode=simSilent, and TfrxReport.EngineOptions.NewSilentMode=simReThrow. None make a difference.
Thanks in advance,
Griffyn
Comments
I've managed a workaround for my issue which works only because, fortunately, TfrxReport throws an exception the first time without the popup window.
So I catch the EInvalidOperation exception and in the exception handler call frxPrinters.FillPrinters; (must add frxPrinter to the uses clause) which fixes the problem on the next attempt to print to that printer. This avoids the popup windows in this case.
However, it would still be nice to know how to suppress all popup alert windows entirely. Any suggestions are welcome.
Create small demo project with error and send it to support@fast-report.com