Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No default printer 1

Status
Not open for further replies.

eladna

Programmer
Dec 11, 2002
17
IL
Hi
I have a program which uses the "printdialog" and the "printsetupdialog".
These components sit at one of the forms (MDI Child).
The problems accords when the user does not have any default printer, in that case he can't reach the form and instead gets an error message "Error reading printdialog1.copies there is no default printer currently selected".

I hope you could help me.
Anyway, thank you very much for your help
 
What do you want your program to do if there is no default printer?

Andrew
Hampshire, UK
 
To open that particular form and most of it do not show the error message
 
I suggest that you create instances of PrinterDialog and PrintSetupDialog at runtime only if the user has a printer.

So your code might look something like:
Code:
var
 PrintDialog: TPrintDialog;
 PrintSetupDialog: TPrintSetupDialog;
...
begin
 ...
 if Printer.Printers.Count > 0 then begin
  PrintDialog := TPrintDialog.Create ( ... );
  PrintSetupDialog := TPrintSetupDialog.Create ( ... );
  try
   ...
   code to call PrintSetupDialog.Execute
   code to call PrintDialog.Execute
   code to actually print document
   ...
  finally
  PrintDialog.Free;
  PrintSetupDialog.Free;
 end;
end;

Andrew
Hampshire, UK
 
Thank you towerbase for your help.
Eventually I haven't used your suggestion, I've found out that the print dialog makes problems only when it been place at fsMDI child or form so I shift it to new normal form and called it from there.
But anyway thanks for your help
Elad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top