Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printersetupdialog starting printer

I'm making an application in Embarcadero Delphi XE2.

I'm using a PrinterSetupDialog to select a printer name into TEdit like:

if PrinterSetupDialog1.Execute() then begin

txtPrinterName.Text := Printer.Printers[Printer.PrinterIndex];
ConfigINI.modified := true;

end;

The problem I have is that this PrinterSetupDialog when executed, always selects the same printer at start. I can switch to another ok and the TEdit gets filled ok.


What I want to do is:

Before executing the PrinterSetupdialog

have it set dialog's selected printer to the one in the TEdit for example:

PrinterSetupDialog.PrinterSelectedAtExecute := txtPrinterName.Text;

Help appreciated. Thanks.

like image 776
Jacek Pietal Avatar asked Dec 26 '22 14:12

Jacek Pietal


1 Answers

You can set the initial selected printer of the printer setup dialog using the Printer function.

uses
  Printers;
 ...
 ...
 begin
   Printer.PrinterIndex:=Printer.Printers.IndexOf(txtPrinterName.Text);
   PrinterSetupDialog1.Execute;
 end;
like image 189
RRUZ Avatar answered Dec 29 '22 04:12

RRUZ